file); fclose($legendFileHandle); $e = new mb_notice("SaveLegend: new legend file created: ".$legend_filename); } else { $e = new mb_exception("SaveLegend: legend file ".$legend_filename." could not be created!"); } //get size of image $size = getimagesize($legend_filename); $width = $size[0]; $height = $size[1]; $image = imagecreatetruecolor($width, $height); $white = ImageColorAllocate($image,255,255,255); ImageFilledRectangle($image,0,0,$width,$height,$white); //load image from url to create new image $img = $this->loadpng($url); if($img != false){ imagecopy($image, $img, 0, 0, 0, 0, $width, $height); }else{ $e = new mb_exception("SaveLegend: unable to load image: " . $url); } //save image to same filename as before imagepng($image,$legend_filename); imagedestroy($img); } /** * Old constructor to keep PHP downward compatibility */ function SaveLegend($url,$legend_filename){ self::__construct($url,$legend_filename); } function loadpng ($imgurl) { $x = new connector($imgurl); try { $im = imagecreatefromstring($x->file); }catch(Exception $E){ $e = new mb_exception("Can't read image from string: ".$E->getmessage); } if(!$im){ $im = false; $e = new mb_exception("SaveLegend: unable to load image: ".$imgurl); } imageinterlace($im, 0); return $im; imagedestroy($im); } } ?>