Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc

   Amazon

   Links

    


Image Scaler (resizer)

 

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)


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
Search an array(C)
draw a chord(VB)
open default browser with a url(VB)
create a database(PHP)
get current process info(VB)
Ban a user(ASP)
background effect(Javascript)
Absread in C(C)

    




Copyright © 2004 by programmershelp.co.uk