Re: Create Thumbnail

This is a discussion on Re: Create Thumbnail within the alt.comp.lang.php forums, part of the PHP Programming Forums category; If you can use GD2 library use this function function create_resampled_image($max_height, $max_width, $image_quality, $image, $newimage){ $src_img = imagecreatefromjpeg($image); $orig_x = ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-09-2003
Juz
 
Posts: n/a
Default Re: Create Thumbnail

If you can use GD2 library use this function

function create_resampled_image($max_height, $max_width, $image_quality,
$image, $newimage){
$src_img = imagecreatefromjpeg($image);
$orig_x = imagesx($src_img);
$orig_y = imagesy($src_img);

$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);

if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}

$dst_img = imagecreatetruecolor($new_x,$new_y);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x,
$orig_y);
imagejpeg($dst_img, $newimage, $image_quality);
imagedestroy($src_img);
imagedestroy($dst_img);
}


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:42 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0