PHPBuilder - Image Resizer



RSS Twitter
Snippets Graphics

Image Resizer

by: Jeff Espiritu
|
October 26, 2004

Version: 1

Type: Function

Category: Graphics

License: GNU General Public License

Description: Resize the image without altering or creating new resized image file. Display your image in thumb or specify the percentage size for fast loading displaying in the browser, no need to created another resized image file, this script will do the job for you, it will not alter the image itself, it will only resize once display in the browser. Sample how to use it : <img scr="resizer.php?imgfile=image.jpg&percent=0.3" border=0>



<?php
/*
Created by http://smallcapitalbusiness.com

Other Scripts we made:
 - Traffic Exchange Link (The New Generation)
 - Simply FAQ Script
 - Write Text to the Image
 - Image Resizer
 - Simple Web Monitoring
 - Capture TGP New listing
 - Exit Popup Exchange Service
 - Domain Redirection Service
 - TGP or Thumbnail Gallery Post

GNU : Do not remove our signature at the bottom page
*/


// File and new size
//$imgfile = 'smp.jpg';
//$percent = 0.2;
header('Content-type: image/jpeg');

list($width, $height) = getimagesize($imgfile);
$newwidth = $width * $percent;
$newheight = $height * $percent;

$thumb = ImageCreateTrueColor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);

imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

imagejpeg($thumb);
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Jeff Espiritu

Comment:



Comment:

(Maximum characters: 1200). You have characters left.