Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Convert color profiles in JPEG into sRGB #94

wants to merge 1 commit into from

4 participants


I encountered a problem with Adaptive Images when using it for Jpeg files that have an embedded color profile. The color profile is lost, as this seems to be not yet supported by the GD library, changing the displayed colors. The problem can be seen here: ; the upper image is the original, the lower one is converted image; the bright red color has changed into something rather brownish.
The only solution I found to this problem was to use an external programm to convert the images into sRGB; the proposed patch uses the program "jpegicc".


Went into the same kind of problem. Do you think Matt Wilcox will add the jpegicc program into the default version of Adaptive-Images? Actually, did he reply to you?


Just want to stay that I also have this problem with managing Color profiles.
Besides that, I also experienced that the images created with Adaptive Images gets pretty bad. If you compress the same image in Photoshop it's all good. I will file a separate issue for this probably.

Below are some comparisons for an image (2560 x 1707):

..the version that Adaptive outputs is half the size, but it looks really bad. Why? Ping @MattWilcox @CatoTH @decarola


Same problem here.

This could also be fixed by enabling Imagick as an alternative to GD library, right?

(I'm using a Wordpress plugin ( for this, but obviously its images are being superseded by Adaptive Images')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 30, 2012
  1. @CatoTH
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 3 deletions.
  1. +10 −2 adaptive-images.php
  2. +5 −1 changelog.txt
12 adaptive-images.php
@@ -18,6 +18,8 @@
$sharpen = TRUE; // Shrinking images can blur details, perform a sharpen on re-scaled images?
$watch_cache = TRUE; // check that the adapted image isn't stale (ensures updated source images are re-cached)
$browser_cache = 60*60*24*7; // How long the BROWSER cache should last (seconds, minutes, hours, days. 7days by default)
+$jpegicc = null;
+#$jpegicc = "jpegicc"; // Path to the "jpegicc" program, which converts color profiles embedded into JPEG-Files into the sRPB colorspace. In debian-based systems, it is contained in the package "liblcms-utils"
/* END CONFIG ----------------------------------------------------------------------------------------------------------
------------------------ Don't edit anything after this line unless you know what you're doing -------------------------
@@ -131,7 +133,7 @@ function refreshCache($source_file, $cache_file, $resolution) {
/* generates the given cache file for the given source file with the given resolution */
function generateImage($source_file, $cache_file, $resolution) {
- global $sharpen, $jpg_quality;
+ global $sharpen, $jpg_quality, $jpegicc;
$extension = strtolower(pathinfo($source_file, PATHINFO_EXTENSION));
@@ -159,7 +161,13 @@ function generateImage($source_file, $cache_file, $resolution) {
$src = @ImageCreateFromGif($source_file); // original image
- $src = @ImageCreateFromJpeg($source_file); // original image
+ if ($jpegicc !== null) {
+ exec($jpegicc . " '" . addslashes($source_file) . "' '" . addslashes($cache_file) . ".tmp.jpg'");
+ $src = @ImageCreateFromJpeg($cache_file . ".tmp.jpg");
+ unlink($cache_file . ".tmp.jpg");
+ } else {
+ $src = @ImageCreateFromJpeg($source_file); // original image
+ }
ImageInterlace($dst, true); // Enable interlancing (progressive JPG, smaller size file)
6 changelog.txt
@@ -1,3 +1,7 @@
+ * The program "jpegicc" can be used to automatically convert all JPEG-images with
+ embedded color profiles into sRGB.
version 1.5.2 (2012/04/16) ------------------------------------------------------------
@@ -279,4 +283,4 @@ beta 1 (2011/08/01) ------------------------------------------------------------
* Commented the PHP for public consumption
* Added user-configurable cache directory (see CONFIG, $cache_path)
- * Didn't generate downscaled images due to typo
+ * Didn't generate downscaled images due to typo
Something went wrong with that request. Please try again.