function build_image($imagepath,$code="",$attr="") { global $build_image_stylesheet; global $build_image_list; global $build_image_dir; $build_image_dir="/temppdf/"; if(!$code) $code="build_image_".count($build_image_list); $img = stat($imagepath); $build_image_list[$code][path]=$imagepath; echo "
"; return $code; } function build_image_write_style($filename, $imagefile) { global $build_image_list; $imagefile=str_ireplace($_SERVER[DOCUMENT_ROOT],"",$imagefile); foreach($build_image_list as $cl=>$img) { extract($img); $out.=" .$cl { width :{$width}px; height:{$height}px; background-position: 0px -{$top}px; } "; $top += $height; } if($out) $out.=" .build_image{ display:inline; display: block; overflow: hidden; background-repeat: no-repeat; background-image:url($imagefile); } "; file_put_contents($filename,$out); } function build_image_write_img($filename) { global $build_image_stylesheet; global $build_image_list; global $build_image_dir; if(!is_array($build_image_list)) return; d(build_image_list,$build_image_list); foreach($build_image_list as $cl=>$img) { d(imgpath,$img); $sz = getimagesize($img[path]); d($sz); list($width, $height) = $sz; d(width,$width); d(height,$height); if(!$width||!$height) continue; $build_image_list[$cl][width]=$width; $build_image_list[$cl][height]=$height; if($width>$maxwidth) $maxwidth=$width; $totalheight+=$height; } if(!$maxwidth||!$totalheight) ddie("canot create iamge, $maxwidth x $totalheight"); $outim = imagecreate($maxwidth,$totalheight); //$background_color = imagecolorallocate($im, 0, 0, 0); //imagecolortransparent ( $outim ,$background_color ); $top=0; foreach($build_image_list as $cl=>$img) { extract($img); if(!$width||!$height) continue; $im= build_image_frompath($path); if(!$im) continue; d($path); d($top,$width); d(imagecopymerge,"$outim,$im,0,$top,0,0,$width,$height,100"); imagecopymerge ($outim,$im,0,$top,0,0,$width,$height,100); $top+=$height; } imagepng($outim,$filename); } function build_image_frompath($imagepath) { $im = @imagecreatefromgif ($imagepath); if(!$im) $im = @imagecreatefromjpeg ($imagepath); if(!$im) $im = @imagecreatefrompng ($imagepath); if(!$im) $im = @imagecreatefromwbmp ($imagepath); return $im; }