View file pages/resize.php

File size: 1.06Kb
<?php
header("Content-type: image/gif");
$image=$_GET["image"];
if(!$image){$resize = imagecreatefromgif("../images/antihacking.gif");}
else {

////Image height i set it up to 60 pixels
$resheight = 80;
/////////////// SCRIPT SETTINGS END   ////////////


$rever=strrev($image);
$prv=explode(".", $rever);
$extension=strrev($prv[0]);
$smallext=strtolower($extension);
$size = GetImageSize($image);
$imawidth = $size[0];
$imaheight = $size[1];

if($smallext=="gif")
 {
 $back = imagecreatefromgif("$image");
 }
if($smallext=="jpeg")
 {
 $back = imagecreatefromjpeg("$image");
 }
if($smallext=="jpg")
 {
 $back = imagecreatefromjpeg("$image");
 }
if($smallext=="png")
 {
 $back = imagecreatefrompng("$image");
 }

if($imaheight<=$resheight)
 {
 $resize=$back;
 }

if($imaheight>$resheight)
 {
 $sizey=$resheight; $sizex=$resheight*$imawidth/$imaheight;
 $resize=ImageCreateTrueColor($sizex,$sizey);
 imagecopyresized($resize, $back, 0, 0, 0, 0, $sizex, $sizey, $imawidth, $imaheight);
 }
 }
imagegif($resize);
imagedestroy($resize);
?>