function icons_graphics_pick($in) { list($w, $h, $ty) = getimagesize($in); if ($ty == 2) { $im = imagecreatefromjpeg($in); } elseif ($ty == 1) { $im = imagecreatefromgif($in); imgalpha($img); } elseif ($ty == 3) { $im = imagecreatefrompng($in); imgalpha($img); } for ($y = 0; $y < $h; $y++) { for ($x = 0; $x < $w; $x++) { $rgb = imagecolorat($im, $x, $y); $clrs[$x][$y] = imagecolorsforindex($im, $rgb); } } return $rgb; }
function make_mini($in, $out, $w, $h, $s) { // $w = $w ? $w : 140; $h = $h ? $h : 100; list($wo, $ho, $ty) = getimagesize($in); list($w, $h, $wo, $ho, $xb, $yb) = scale_img($w, $h, $wo, $ho, $s); if (is_file($in)) { if (filesize($in) / 1024 > 5000) { return; } } //if($ho<$w or $wo<$h)return; //if($w>=$wo && $h>=$ho){if(is_file($out))unlink($out); return $in;} $img = imagecreatetruecolor($w, $h); //$c=imagecolorallocate($img,255,255,255); imagefill($img,0,0,$c); if ($ty == 2) { $im = imagecreatefromjpeg($in); imagecopyresampled($img, $im, $xa, $ya, $xb, $yb, $w, $h, $wo, $ho); imagejpeg($img, $out, 100); } elseif ($ty == 1) { $im = imagecreatefromgif($in); imgalpha($img); imagecopyresampled($img, $im, $xa, $ya, $xb, $yb, $w, $h, $wo, $ho); imagegif($img, $out); } elseif ($ty == 3) { $im = imagecreatefrompng($in); imgalpha($img); // imagecopyresampled($img, $im, $xa, $ya, $xb, $yb, $w, $h, $wo, $ho); imagepng($img, $out); } return $out; }