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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.