blueimp / JavaScript-Load-Image

Load images provided as File or Blob objects or via URL. Retrieve an optionally scaled, cropped or rotated HTML img or canvas element. Use methods to parse image metadata to extract IPTC and Exif tags as well as embedded thumbnail images, to overwrite the Exif Orientation value and to restore the complete image header after resizing.
https://blueimp.github.io/JavaScript-Load-Image/
MIT License
4.46k stars 923 forks source link

ICC Profile data gets lost after resizing #105

Open thehappycoder opened 4 years ago

thehappycoder commented 4 years ago

First of all, thank you for this wonderful package!

I call replaceHead to keep some metadata after resizing an image, but according to http://metapicz.com/#landing the ICC Profile data gets lost.

I also do this before replacing the header:

loadImage.writeExifData(
              imageMetaData.imageHead,
              imageMetaData,
              'Orientation',
              1
            )
blueimp commented 4 years ago

Thanks for the report @thehappycoder.

Can you provide a sample image?

Have you tried increasing the possible header size via maxMetaDataSize?

While this library does not parse ICC data, it should include all APPn and COMMENT markers (ICC data being one of them) in the image head (given a high enough maxMetaDataSize): https://github.com/blueimp/JavaScript-Load-Image/blob/4d8377763069ce017935d86c625000fbe28cad3d/js/load-image-meta.js#L105-L141

In my tests, the ICC profile data from sample images (e.g. from http://regex.info/blog/photo-tech/color-spaces-page2) was still attached, but the color profile was not correctly applied anymore.

fleitnerfischer commented 2 years ago

Hi @blueimp, looks like the issue is still there?

olivierbelzile commented 2 years ago

I can confirm that from my test the issue is still there. The ICC profile is still included in the resized image but the color are wrong. To me it looks like the profile is applied twice rather than not. Maybe the solution is to drop the custom color profile from the resized image instead of trying to preserve it.