Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICC Profile data gets lost after resizing #105

Open
thehappycoder opened this issue Apr 28, 2020 · 3 comments
Open

ICC Profile data gets lost after resizing #105

thehappycoder opened this issue Apr 28, 2020 · 3 comments

Comments

@thehappycoder
Copy link

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
Copy link
Owner

blueimp commented Apr 28, 2020

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):

// Search for APPn (0xffeN) and COM (0xfffe) markers,
// which contain application-specific meta-data like
// Exif, ICC and IPTC data and text comments:
if (
(markerBytes >= 0xffe0 && markerBytes <= 0xffef) ||
markerBytes === 0xfffe
) {
// The marker bytes (2) are always followed by
// the length bytes (2), indicating the length of the
// marker segment, which includes the length bytes,
// but not the marker bytes, so we add 2:
markerLength = dataView.getUint16(offset + 2) + 2
if (offset + markerLength > dataView.byteLength) {
// eslint-disable-next-line no-console
console.log('Invalid meta data: Invalid segment size.')
break
}
parsers = loadImage.metaDataParsers.jpeg[markerBytes]
if (parsers && !options.disableMetaDataParsers) {
for (i = 0; i < parsers.length; i += 1) {
parsers[i].call(
that,
dataView,
offset,
markerLength,
data,
options
)
}
}
offset += markerLength
headLength = offset
} else {
// Not an APPn or COM marker, probably safe to
// assume that this is the end of the meta data
break
}

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
Copy link

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

@olivierbelzile
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants