Re: Create Thumbnail

Posted: 07-09-2003, 10:34 PM
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

Responses to "Re: Create Thumbnail"

Guillaume JANY
Guest
Posts: n/a
 
Re: Create Thumbnail
Posted: 07-10-2003, 12:13 PM
> I'm looking for exactly the following script
> http://alt-php-faq.org/local/105/.
> But the quality of the result is horrible.
replace line $dst_img = imagecreate($new_w,$new_h);
with line $dst_img = imagecreatetruecolor($new_w,$new_h);

you may also build a x2 thumbnail

imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w* 2,$new_h*2,imagesx($src_im
g),imagesy($src_img));

and display it with width=$new_w, height=$new_h

Guillaume
www.designerspace.com



Reply With Quote
s a n j a y
Guest
Posts: n/a
 
Re: Create Thumbnail
Posted: 07-10-2003, 02:14 PM
I have written a script for a commercial website to resize images. If you
still want it email me at ski_sanjay@yahoo.com

sanjay


"Thür Thomas" <thomasFUCKK@SSPAMMMthuer.com> wrote in message
news:3f0c927e$0$22092$5402220f@news.sunrise.ch...
> Hello NG
>
> I'm looking for exactly the following script
> http://alt-php-faq.org/local/105/.
> But the quality of the result is horrible.
> The original pic: http://www.neonthaler.ch/test/moose.jpg
> The small pic: http://www.neonthaler.ch/test/moose2.jpg
>
> Has someone a script with the same function and better results?
>
> Thx for your help.
> Thomas
>
>

Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thumbnail creation while uploading VincentRommelaars Macromedia Exchange Dreamweaver Extensions 2 12-12-2005 02:59 AM
Cannot create SQL DSN TingB Coldfusion Database Access 2 02-24-2005 06:57 PM
Create folders stevenlmas Dreamweaver AppDev 0 02-16-2005 08:11 PM
Create PDF Menu ANW@adobeforums.com Adobe Acrobat Macintosh 4 08-01-2004 06:46 AM
Acrobat 4.0 creates thumbnail not full size view of page? Susan_Sharman@adobeforums.com Adobe Acrobat Macintosh 1 07-26-2004 09:28 PM