esimov / caire

Content aware image resize library
MIT License
10.36k stars 384 forks source link

Preserve Jpeg color profile #82

Closed purplefish32 closed 2 years ago

purplefish32 commented 2 years ago

When I try to use the lib on a jpeg input file to a jpeg output format the colour profile is not preserved resulting in a shifting in the output colours

The solution would possibly be to retain the input colour profile or being able to assign a desired colour profile to the output

esimov commented 2 years ago

What do you mean by color space is not preserved? Could you explain? Even better would be if you could attach the source image and the resulted output.

purplefish32 commented 2 years ago

The first one (in) is in Adobe RGB (1998) colour profile, the second one (out) becomes sRGB ICE61966-2.1

Notice the colours are also less vibrant.

Screenshot 2022-09-22 at 14 55 25

This is the command I am using :

caire -in beach.jpg -width 1969 -out beach2.jpg -debug=1

So here are the two images :

beach beach (1)

purplefish32 commented 2 years ago

Once uploaded to Github, both the in and out image seem to be more or less the same, I think the Github image preview is reincoding them or something,

You can try a download one and use caire on it to reproduce the issue

purplefish32 commented 2 years ago

And sorry it is the colour profile that changes, not the colour space

esimov commented 2 years ago

I've done a little research, but unfortunately the image package does not preserve the color profile of the original image on encoding. There are other tools like exiftool where you can modify the color profile of an image or libvips which actually has a go binding also, but I'm not planning of integrating into Caire.

purplefish32 commented 2 years ago

OK, thank you for taking the time to investigate