lordphate Posted February 15, 2007 Share Posted February 15, 2007 Hi everyone, Okay i have a image resizing script that works well when you're uploading certain photos. BUT I'm wanting to make a Maximum and Minimum requirement... Meaning... If someone uploads a big photo , i want it to resize to a medium, size(maximum of 250(width) x 250 (height) sounds simple enough right...well i also want to make it where if someone uploads a photo SMALLER than 250 x 250, it doesn't reduce it at all... AND i want to make it where it will keep the same ratio.. heres what i have now $size = GetImageSize($photos_uploaded['tmp_name'][$counter]); $photo_width = ($size[0] * .50); $photo_height = ($size[1] * .50); $function_suffix = $gd_function_suffix[$filetype]; $function_to_read = 'ImageCreateFrom' . $function_suffix; $function_to_write = 'Image' . $function_suffix; $source_handle = $function_to_read($photos_uploaded['tmp_name'][$counter]); if ($source_handle) { $destination_handle = ImageCreateTrueColor($photo_width, $photo_height); ImageCopyResampled($destination_handle, $source_handle, 0, 0, 0, 0, $photo_width, $photo_height, $size[0], $size[1]); } $function_to_write($destination_handle, $images_dir . '/' . $filename); Link to comment https://forums.phpfreaks.com/topic/38550-solved-image-resizing/ Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Share Posted February 15, 2007 What exactly do you want? If smaller image is uploaded, you want it to be resized to selected value, or you want to leave it as it was? Link to comment https://forums.phpfreaks.com/topic/38550-solved-image-resizing/#findComment-185104 Share on other sites More sharing options...
lordphate Posted February 15, 2007 Author Share Posted February 15, 2007 as it was Link to comment https://forums.phpfreaks.com/topic/38550-solved-image-resizing/#findComment-185172 Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Share Posted February 15, 2007 I would do like this: <? $max_width = 300; //Set whatever you want $max_height = 300; //Whatever you want list($width, $height) = getimagesize('path/to/yourfile.jpg'); if($width <= $max_width && $height <= $max_height) { print "Picture is smaller than 300*300 pixels."; //Or put your code here } else //in case image is bigger { PUT YOUR CODE HERE } ?> Hope this is it Link to comment https://forums.phpfreaks.com/topic/38550-solved-image-resizing/#findComment-185470 Share on other sites More sharing options...
EagerWolf Posted February 15, 2007 Share Posted February 15, 2007 BTW .. I didn't look all your code before ... Above is just example how would I check image size and than decide what to do... Link to comment https://forums.phpfreaks.com/topic/38550-solved-image-resizing/#findComment-185476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.