<?php
// Resize image.
// Writeen By: Smelban & Haker4o
// Mails [email protected] & [email protected]
// This code is written to only execute on jpg,gif,png
// $picname = resizepics('pics', 'new widthmax', 'new heightmax');
// Demo $picname = resizepics('stihche.jpg', '180', '140');
$picname = resizepics('picture-name.format', '180', '140');
echo $pickname;
//Error
die( "<font color=\"#FF0066\"><center><b>File not exists :(<b></center></FONT>");
//Funcion resizepics
function resizepics($pics, $newwidth, $newheight){
if(preg_match("/.jpg/i", "$pics")){
header('Content-type: image/jpeg');
}
if (preg_match("/.gif/i", "$pics")){
header('Content-type: image/gif');
}
list($width, $height) = getimagesize($pics);
if($width > $height && $newheight < $height){
$newheight = $height / ($width / $newwidth);
} else if ($width < $height && $newwidth < $width) {
$newwidth = $width / ($height / $newheight);
} else {
$newwidth = $width;
$newheight = $height;
}
if(preg_match("/.jpg/i", "$pics")){
$source = imagecreatefromjpeg($pics);
}
if(preg_match("/.jpeg/i", "$pics")){
$source = imagecreatefromjpeg($pics);
}
if(preg_match("/.jpeg/i", "$pics")){
$source = Imagecreatefromjpeg($pics);
}
if(preg_match("/.png/i", "$pics")){
$source = imagecreatefrompng($pics);
}
if(preg_match("/.gif/i", "$pics")){
$source = imagecreatefromgif($pics);
}
$thumb = imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return imagejpeg($thumb);
if(preg_match("/.jpg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.jpeg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.jpeg/i", "$pics")){
return imagejpeg($thumb);
}
if(preg_match("/.png/i", "$pics")){
return imagepng($thumb);
}
if(preg_match("/.gif/i", "$pics")){
return imagegif($thumb);
}
}
?>