update page now

Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

marcy DOT xxx (AT) gmail.com
21 years ago
This example allow to use every kind of image and to resize images with ImageCopyResized(), maintaining proportions..

<?php
// switch to find the correct type of function

$imgfile = 'namefile.jpg';
Header("Content-type: image/".$_GET["type"]);

switch($_GET["type"]){
default:
    $function_image_create = "ImageCreateFromJpeg";
    $function_image_new = "ImageJpeg";
break;
case "jpg":
    $function_image_create = "ImageCreateFromJpeg";
    $function_image_new = "ImageJpeg";
case "jpeg":
    $function_image_create = "ImageCreateFromJpeg";
    $function_image_new = "ImageJpeg";
break;
case "png":
    $function_image_create = "ImageCreateFromPng";
    $function_image_new = "ImagePNG";
break;
case "gif":
    $function_image_create = "ImageCreateFromGif";
    $function_image_new = "ImagePNG";
break;
}

list($width, $height) = getimagesize($imgfile);

// the new weight of the thumb

$newheight = 80;

// Proportion is maintained

$newwidth = (int) (($width*80)/$height);

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

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

@$function_image_new($thumb);
?>

<< Back to user notes page

To Top