function get_im tmp_name switch exif_imagetype tmp_name case IMAGETYPE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<?
function get_im($tmp_name) {
switch(exif_imagetype($tmp_name)) {
case IMAGETYPE_JPEG:
return imagecreatefromjpeg($tmp_name);
break;
case IMAGETYPE_PNG:
return imagecreatefrompng($tmp_name);
break;
case IMAGETYPE_GIF:
return imagecreatefromgif($tmp_name);
break;
default:
return false;
break;
}
}
$im = get_im($tmp_name);
echo imagesy($im);