<?
$width = "100";
$height = "100";
$source = "test.gif";

$size = getimagesize($source);
$num = exif_imagetype($source);
switch ($num) {
  case 1: $create = imagecreatefromgif($source); break;
  case 2: $create = imagecreatefromjpeg($source); break;
  case 3: $create = imagecreatefrompng($source); break;
  case 7: $create = imagecreate($source); break;
  default: die();
}
$temp = imagecreatetruecolor($width, $height);
imagecopyresized($temp, $create, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
imagedestroy($create);
imagejpeg($temp);
?>
Published in: PHP
Download

Related snippets