Login   Register  
PHP Classes
elePHPant
Icontem

File: resize.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of George Clarke  >  ABrowser Class  >  resize.php  >  Download  
File: resize.php
Role: Auxiliary script
Content type: text/plain
Description: Resizes and displays images
Class: ABrowser Class
Browse server side files and folders
Author: By
Last change: Corrected a few errors in the resize.php script. If error reporting is turned on, it would prevent the images from being displayed.
Date: 8 years ago
Size: 1,164 bytes
 

Contents

Class file image Download
<?php
//a resize script
$width=(isset($_GET['w']))?$_GET['w']:0;
$height=(isset($_GET['h']))?$_GET['h']:0;
$ffile=(isset($_GET['f']))?$_GET['f']:"";

// Content type
header('(anti-spam-content-type:) image/jpeg');

// Get new dimensions
list($widthorig$heightorig) = getimagesize($ffile);
if(!
$width && !height){
 
$width=$widthorig;
 
$height=$heightorig;
}
if(
$width && !$height){
 
$width=($width $widthorig) ? $widthorig $width;
 
$height =($width $widthorig) ? $heightorig : ($heightorig $widthorig) * $width;
}
if(
$height && !$width){
 
$height=($height $heightorig) ? $heightorig $height;
 
$width = ($height $heightorig) ? $widthorig : ($widthorig $heightorig) * $height;
}
  
$extn=explode(".",$ffile);
  
$i=count($extn);
  
$ext=strtolower($extn[$i-1]);

// Resample
$imagep imagecreatetruecolor($width$height);
  if(
$ext=="jpg")$image=imagecreatefromjpeg($ffile);
  if(
$ext=="png")$image=imagecreatefrompng($ffile);
  if(
$ext=="gif")$image=imagecreatefromgif($ffile);
imagecopyresampled($imagep$image0000$width$height$widthorig$heightorig);

// Output
imagejpeg($imagepnull100);
?>