Jump to content

[SOLVED] image resize problems


Lodius2000

Recommended Posts

Hi my image resizer works fine if the image is a horizontal but not a vertical

attached are what the input and output looks like, 071808_08orig.jpg turns into 071808_08sm.jpg

 

<?php
$src_sm   = imagecreatefromjpeg($uploadedfile); //$uploadedfile comes from a form
$sm_pixels = 250;
$sm_height = 250;

// Get dimensions of original
list($width_orig, $height_orig) = getimagesize($uploadedfile);



if ($width_orig >= $height_orig) {

                //this is for horizontal resizement and works fine, so code is omitted

        } else {
	$new_sm_width=($width_orig/$height_orig)*$sm_pixels;
	$tmp_sm=imagecreatetruecolor($new_bg_width,$sm_height);
	imagecopyresampled($tmp_sm,$src_sm,0,0,0,0,$new_sm_width,$sm_height,$width_orig,$height_orig);
}
//$filename_sm contains a path and filename to be saved
imagejpeg($tmp_sm,$filename_sm,100);
?>

 

so what am i doing wrong, the vertical dimension is right, 250, but the horizontal dimension is 341, where is that coming from

 

thanks

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/115543-solved-image-resize-problems/
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.