Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

A resizing example that keeps the aspect ratio of the image intact. the ratio is passed to the script and then the length and width are divided by that.

<?php
header("Content-type: image/jpeg");
//get the scale setting
$scale = $HTTP_GET_VARS['scale'];
//our test image
$img = "test.jpg";
$input_image = ImageCreateFromJPEG("$img");
//scale the image
$image_width = ImageSX($input_image) / $scale;
$image_height = ImageSY($input_image) / $scale;
//create new image
$output_image = ImageCreate($image_width, $image_height);
//resize new image
ImageCopyResized($output_image, $input_image, 0, 0, 0, 0, $image_width, $image_height, ImageSX($input_image), ImageSY($input_image));
//output image
ImageJPEG($output_image);
//clean up
ImageDestroy($input_image);
ImageDestroy($output_image);
?>

 

scale by 2 example
scale by 4 example
scale by 1 example (normal size)