@@ -326,7 +326,7 @@ class PipelineWorker : public Napi::AsyncWorker {
326326 try {
327327 image = image.icc_transform (processingProfile, VImage::option ()
328328 ->set (" embedded" , TRUE )
329- ->set (" depth" , image.interpretation () == VIPS_INTERPRETATION_RGB16 ? 16 : 8 )
329+ ->set (" depth" , sharp::Is16Bit ( image.interpretation ()) ? 16 : 8 )
330330 ->set (" intent" , VIPS_INTENT_PERCEPTUAL));
331331 } catch (...) {
332332 sharp::VipsWarningCallback (nullptr , G_LOG_LEVEL_WARNING, " Invalid embedded profile" , nullptr );
@@ -763,6 +763,7 @@ class PipelineWorker : public Napi::AsyncWorker {
763763 if (baton->withMetadata && sharp::HasProfile (image) && baton->withMetadataIcc .empty ()) {
764764 image = image.icc_transform (" srgb" , VImage::option ()
765765 ->set (" embedded" , TRUE )
766+ ->set (" depth" , sharp::Is16Bit (image.interpretation ()) ? 16 : 8 )
766767 ->set (" intent" , VIPS_INTENT_PERCEPTUAL));
767768 }
768769 }
@@ -789,14 +790,13 @@ class PipelineWorker : public Napi::AsyncWorker {
789790
790791 // Apply output ICC profile
791792 if (baton->withMetadata ) {
792- if (image.interpretation () == VIPS_INTERPRETATION_sRGB || !baton->withMetadataIcc .empty ()) {
793- image = image.icc_transform (
794- baton->withMetadataIcc .empty () ? " srgb" : const_cast <char *>(baton->withMetadataIcc .data ()),
795- VImage::option ()
796- ->set (" input_profile" , processingProfile)
797- ->set (" embedded" , TRUE )
798- ->set (" intent" , VIPS_INTENT_PERCEPTUAL));
799- }
793+ image = image.icc_transform (
794+ baton->withMetadataIcc .empty () ? " srgb" : const_cast <char *>(baton->withMetadataIcc .data ()),
795+ VImage::option ()
796+ ->set (" input_profile" , processingProfile)
797+ ->set (" embedded" , TRUE )
798+ ->set (" depth" , sharp::Is16Bit (image.interpretation ()) ? 16 : 8 )
799+ ->set (" intent" , VIPS_INTENT_PERCEPTUAL));
800800 }
801801 // Override EXIF Orientation tag
802802 if (baton->withMetadata && baton->withMetadataOrientation != -1 ) {
0 commit comments