PHP image output suddenly stopped working -


i have file manipulates images before output browser. here code:

<?php require_once($_server["document_root"].'/_content/_constants.php'); require_once($_server["document_root"].'/_content/_functions.php');      function hex2rgb($hex) {        $hex = str_replace("#", "", $hex);         if(strlen($hex) == 3) {           $r = hexdec(substr($hex,0,1).substr($hex,0,1));           $g = hexdec(substr($hex,1,1).substr($hex,1,1));           $b = hexdec(substr($hex,2,1).substr($hex,2,1));        } else {           $r = hexdec(substr($hex,0,2));           $g = hexdec(substr($hex,2,2));           $b = hexdec(substr($hex,4,2));        }        $rgb = array($r, $g, $b);        //return implode(",", $rgb); // returns rgb values separated commas        return $rgb; // returns array rgb values     }      /*-- hex color code url query --*/     $rgb = hex2rgb((isset($_get["color1"]) && $_get["color1"] != '' ? $_get["color1"] : "c9aa14"));      /*-- image file --*/     $im = imagecreatefrompng (base."/_content/images/".$_get["img"]);      /*-- preserve transparency --*/     imagealphablending($im, false);     imagesavealpha($im, true);       //$index = imagecolorclosest( $im,  0,0,0 ); // original color         //imagecolorset($im,imagecolorat($im,8,8), $rgb2[0],$rgb2[1],$rgb2[2] ); // set color of icon symbol      /*-- apply colorizing filter --*/     imagefilter($im, img_filter_colorize, $rgb[0],$rgb[1],$rgb[2], 0);      /*-----------------------------------------------     * if image has symbol/foreground      * on it, such audio/video icons,      * sets color of symbol     *     * not needed single color images     */     //imagefilltoborder($im, 18, 21, imagecolorat($im,23,10), imagecolorallocate($im,0,0,0));         header("content-type: image/png");     imagepng($im);   ?> 

as of few days ago, whenever try load images through file, the image {path-to-file} cannot displayed because contains errors.

i've searched answers issue , seems gets error doing because they're outputting stuff before header(), not problem in case. know must have changed server-side because working fine long time, , stopped working. tested script on server , worked fine.

i ran gd support test script on server these results:

gd supported server! gd version          yes freetype support    yes freetype linkage    yes t1lib support       no gif read support    yes gif create support  yes jpeg support        yes png support         yes wbmp support        yes xpm support         no xbm support         yes jis-mapped japanese font support    no 

the main problem have don't know enough server requirements php gd functionality, need direction should @ possible culprits in case. possibly have caused break?

before sending header file type try clearing buffer:

// clean output buffer //http://www.php.net/manual/en/function.ob-clean.php#75694 ob_clean();  header("content-type: image/jpeg"); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -