Jump to content

image resizing


Woodburn2006

Recommended Posts

i use this code to resize images that i upload for my website

 

$save = 'thumbs/rocks1121.jpg';

$file = 'rocks.jpeg';

$size = 0.45;

header('Content-type: image/jpeg');

list($width, $height) = getimagesize($file);
$modwidth = $width * $size;
$modheight = $height * $size;

$tn= imagecreatetruecolor($modwidth, $modheight);
$source = imagecreatefromjpeg($file);

imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); 

imagejpeg($tn, $save, 100) ;

 

it works well enough but it is only good if the images are of the same size and the same orientation. what i want to be able to do is have all of my thumbs the same size even if the original pic is a different size.

 

so for example, if the img it is linking to portrait i still want the thumb to be 100x30 pixels but not a stretched version of the image.

 

so basically i want it to take a 100x30 portion of the original and use that as the thumbnail.

 

is there a way of doing this?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/153321-image-resizing/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.