How properly convert created Image with GD to sRGB

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
dmf
Posts: 3
Joined: 2016-12-08T08:12:54-07:00
Authentication code: 1151

How properly convert created Image with GD to sRGB

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How properly convert created Image with GD to sRGB

Post 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.
snibgo's IM pages: im.snibgo.com
dmf
Posts: 3
Joined: 2016-12-08T08:12:54-07:00
Authentication code: 1151

Re: How properly convert created Image with GD to sRGB

Post by dmf »

Ok, that same a little better, but still not as the original :

http://regex.info/exif.cgi?dummy=on&img ... test20.jpg
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How properly convert created Image with GD to sRGB

Post by snibgo »

What version of ImageMagick are you using?
dmf wrote:$image->transformImageColorspace(13);
Why are you doing this?
snibgo's IM pages: im.snibgo.com
dmf
Posts: 3
Joined: 2016-12-08T08:12:54-07:00
Authentication code: 1151

Re: How properly convert created Image with GD to sRGB

Post 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 !
Post Reply