aelvan / Imager-Craft

This plugin has been DEPRECATED. Check out Imager X instead.
MIT License
342 stars 69 forks source link

Strip META but Preserve ICC Color Profiles #278

Open terryupton opened 4 years ago

terryupton commented 4 years ago

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?

bossanova808 commented 4 years ago

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',

aelvan commented 4 years ago

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

terryupton commented 4 years ago

@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?

bossanova808 commented 4 years ago

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