Imager-Craft icon indicating copy to clipboard operation
Imager-Craft copied to clipboard

Strip META but Preserve ICC Color Profiles

Open terryupton opened this issue 4 years ago • 4 comments

Is there any way Imager could be configured to strip the meta data but only keep the ICC Color Profiles? I believe this would still result in slightly smaller sizes, one of the benefits of removing the META data, but still ensuring the image is correct.

I have a series of black and white images that are getting darkened when I set 'removeMetadata' => true, but setting it to false is adding a good 30KB to the larger images.

Here are some comparisons.

Original Image JTQ2018-87

'removeMetadata' => false JTQ2018-87_W2400_H3300_Mcrop_P60-2-27-18_E_grayscale- 313KB 1164 × 1601px Colour space: Grey Colour Profile: Generic Gray Gamma 2.2 Profile

'removeMetadata' => true JTQ2018-87_W2400_H3300_Mcrop_P60-2-27-18_E_grayscale- 289KB 1164 × 1601px Colour space: Grey

I am not entirely sure where the Colour space: grey is getting set? is this something Imager/iMagick is doing?

terryupton avatar Oct 07 '19 08:10 terryupton

This should really be the default option for all these image optimisiation things - stripping ICC profiles is not a lossless operation (especially in a world no colour managed web browsers as we now live in).

@terryupton You can generally solve this at your end for now by using your own option string for the optimisations e.g. jpegoptim use something like:

'optionString' => '--strip-com --strip-exif --strip-iptc --all-progressive',

bossanova808 avatar Oct 12 '19 04:10 bossanova808

I'll put this on my todo-list for the next version of Imager I'm working on, and see what I can come up with. At the moment I'm using the built-in strip method in Imagine, which doesn't allow for any fine-grained removal - it's all or nothing - so I'll have to roll my own functionality then.

@terryupton Just to be clear, you're only transforming the image using width/height and similar, or are you also doing effects: { grayscale: true } on them?

@bossanova808 That's a nice hack. :)

aelvan avatar Oct 12 '19 17:10 aelvan

@aelvan no effects just size transforms. Interestingly is does add _greyscale- to the end of the transformed filename, so it seems like something else might be occurring behind the scenes or as a bug?

terryupton avatar Oct 12 '19 20:10 terryupton

(I am using effects....can't deal with transforms without some image sharpening happening!)

bossanova808 avatar Oct 12 '19 21:10 bossanova808