Page 1 of 1

How properly convert created Image with GD to sRGB

Posted: 2016-12-08T08:21:03-07:00
by dmf
I have to work with an image with PHP GD. The problem is when I copy the original picture, the colors are not the same.

My original Picture :

http://regex.info/exif.cgi?imgurl=https ... euil_3.jpg

People told me to convert my jpg into sRGB profil instead AdobeRPG.

So I did it in PHP :

Code: Select all

	
	
	$image = new Imagick($chemin_image);

	// On enleve tout les profils qu'il y avait à la base
	$image->profileImage('*' , false);

	// Essayer de mettre en SRGB si ce n'est pas le cas
	$icc_srgb = file_get_contents('profil_icc/sRGB_IEC61966-2-1_black_scaled.icc');

	$image->profileImage('icc' , $icc_srgb);
	$image->transformImageColorspace(13);

	$image->writeImage($chemin_image);
	
The colors are the same, but the contraste is now different :
http://regex.info/exif.cgi?dummy=on&im ... plat-7.jpg

I know that not the same size and the same quality, is normal.

I went to Facebook, to see, how he does in his own upload system, I tried with my picture and it's work very well, but i have no idea how they have done.

How can I properly convert all JPEG file to sRGB ?

Thank you.

Re: How properly convert created Image with GD to sRGB

Posted: 2016-12-08T08:33:21-07:00
by snibgo
dmf wrote:$image->profileImage('*' , false);
This removes the Adobe profile, so the image can't then be accurately converted to sRGB. Don't do this.

Re: How properly convert created Image with GD to sRGB

Posted: 2016-12-08T08:59:53-07:00
by dmf
Ok, that same a little better, but still not as the original :

http://regex.info/exif.cgi?dummy=on&img ... test20.jpg

Re: How properly convert created Image with GD to sRGB

Posted: 2016-12-08T09:17:33-07:00
by snibgo
What version of ImageMagick are you using?
dmf wrote:$image->transformImageColorspace(13);
Why are you doing this?

Re: How properly convert created Image with GD to sRGB

Posted: 2016-12-08T09:22:59-07:00
by dmf
You are a genius,

$image->transformImageColorspace(13); is not required

This work perfectly simply :

Code: Select all

	$image = new Imagick($chemin_image);

	// Essayer de mettre en SRGB si ce n'est pas le cas
	$icc_srgb = file_get_contents('../../admin-cache/profil_icc/sRGB_v4_ICC_preference.icc');

	$image->profileImage('icc' , $icc_srgb);
Thank you a lot !