Script issue under PHP 5.2
<p>I have the following code that works just fine, though i can't seem to make it run properly under PHP 5.2* and due to the restrictions where the code is being moved to, it has to work.</p>

<p>There is no error message, the image is simply not created properly (under PHP5.2). This would be the regular outcome for a 100% image bar: <img src="http://i.stack.imgur.com/FoDNo.jpg" alt="i46.tinypic.com/2gy3ce1.jpg"> (working in 5.1 and 5.3 environments) This is the outcome i get under 5.2: <img src="http://i.stack.imgur.com/7p72h.png" alt="i47.tinypic.com/33yt01g.png"></p>

<p>I wonder if there is someone that might know of a work around to make this work under such version. Any help would be great.</p>

<pre><code>&lt;?php
    function loadpng($imgname) {
        $im = @imagecreatefrompng($imgname);
        if(!$im) {
            $im = imagecreatetruecolor(89, 10);
            $bgc = imagecolorallocate($im, 255, 255, 255);
            $tc = imagecolorallocate($im, 0, 0, 0);
            imagefilledrectangle($im, 0, 0, 89, 10, $bgc);
            imagestring($im, 1, 5, 5, 'Error loading bar', $tc);
        }
        return $im;
    }
    header('Content-Type: image/png');
    $img = loadpng('bar.png');
    $impb = imagecreatetruecolor(89, 10);
    // percentage (%)
    $percentage = round($_GET['p']);
    if($percentage &lt; 0) {
        $percentage = 0;
    }
    if($percentage &gt; 100) {
        $percentage = 100;
    }
    $full_min = 0;
    $full_max = 88;
    $empty_max = 178;
    $empty_min = 89;
    $full_s = round( $full_max * $percentage / 100 );
    imagecopy($impb, $img, 0, 0, $full_min, 0, $full_s, 10);
    $dst_x = $full_s;
    $src_x = $empty_min + $full_s;
    $src_w = round(($empty_max - $empty_min) * (100 - $percentage) / 100);
    imagecopy($impb, $img, $dst_x, 0, $src_x, 0 , $src_w , 10);
    imagepng($impb);
    imagedestroy($img);
    imagedestroy($impb);
?&gt;
</code></pre>
