<?php
$filename="1.png";
list($src_w,$src_h,$imagetype)=getimagesize($filename);
$mime=image_type_to_mime_type($imagetype);
//echo $mime;
$createfun=str_replace("/","createfrom",$mime);
$outfun=str_replace("/",null,$mime);
$src_image=$createfun($filename);
$dst_50_image=imagecreatetruecolor(50,50);
$dst_222_image=imagecreatetruecolor(222,222);
$dst_350_image=imagecreatetruecolor(350,350);
$dst_800_image=imagecreatetruecolor(800,800);
imagecopyresampled($dst_50_image, $src_image, 0, 0, 0, 0,50, 50, $src_w, $src_h);
imagecopyresampled($dst_222_image, $src_image, 0, 0, 0, 0,222, 222, $src_w, $src_h);
imagecopyresampled($dst_350_image, $src_image, 0, 0, 0, 0,350,350, $src_w, $src_h);
imagecopyresampled($dst_800_image, $src_image, 0, 0, 0, 0,800, 800, $src_w, $src_h);
$outfun($dst_50_image,'uploads/images_50/'.$filename);
$outfun($dst_222_image,'uploads/images_222/'.$filename);
$outfun($dst_350_image,'uploads/images_350/'.$filename);
$outfun($dst_800_image,'uploads/images_800/'.$filename);
imagedestroy($src_image);
imagedestroy($dst_50_image);
imagedestroy($dst_222_image);
imagedestroy($dst_350_image);
imagedestroy($dst_800_image);
?>