Photo color loss after watermarking
<p>Having a few teething problems watermarking a photo. It all works fine apart from the watermarked photo's colors become duller than they should be - very noticeable in-fact.</p>

<p>I'm using <strong>imagecopyresized</strong> to do my watermarking, as this specifically allows me to use PNG-24 watermarks, the others do not. I know the colors are usually OK, as I have just used <strong>readfile($url)</strong> as a test, and the photos are perfect.</p>

<p>Here is my script:</p>

<pre><code>&lt;?php

// get parent and watermark images &amp; sizes
$image = imagecreatefromjpeg($url);
$imageSize = getimagesize($url);
$watermark = imagecreatefrompng('watermark.png');
$watermark_o_width = imagesx($watermark);
$watermark_o_height = imagesy($watermark);

// calculate new watermark width and position
if ($imageSize[0] &gt; $imageSize[1] || $imageSize[0] == $imageSize[1]) {
    $leftPercent = 23;
} else {
    $leftPercent = 7;
}
$leftPixels = ($imageSize[0]/100)*$leftPercent;
$newWatermarkWidth = $imageSize[0]-$leftPixels;
$newWatermarkHeight = $watermark_o_height * ($newWatermarkWidth / $watermark_o_width);

// place watermark on parent image, centered and scaled
imagecopyresized(
    $image,
    $watermark,
    $imageSize[0]/2 - $newWatermarkWidth/2,
    $imageSize[1]/2 - $newWatermarkHeight/2,
    0,
    0,
    $newWatermarkWidth,
    $newWatermarkHeight,
    imagesx($watermark),
    imagesy($watermark)
);

// print
imagejpeg($image);

// destroy
imagedestroy($image);
imagedestroy($watermark);

?&gt;
</code></pre>

<p>How can I stop this from happening? I'm reading about <strong>imagecreatetruecolor</strong>, does that solve the issue? I'm Googling "imagecreatetruecolor color loss photos" and variations but nobody really talks about this issue. If I do need this function, where would I add that to this script?</p>

<p>This has totally thrown a spanner in the works for me and would love for somebody to tell me where to stick it (not literally).</p>

<p>Here is an example of the color loss. The preview image should be exactly the same colors as the thumbnail. The thumbnails are created using <strong>readfile()</strong> whereas the previews are created using <strong>imagecreatefromjpeg</strong> and <strong>imagecopresized</strong>.</p>

<p><img src="http://i.stack.imgur.com/OmpZC.png" alt="enter image description here"></p>
