Jump to content


php upload, resizing issue

  • Please log in to reply
No replies to this topic

#1 majocmatt

  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 01 May 2006 - 03:28 PM

I'm wanting to make an upload script, which first checks if the image's width is over 500px, and if so, create a new file and resize image to 500px width and resize height proportionately to the new width.

Now a script that I have always used that creates new thumbnails for each photo in my gallery, but thats a hard and fast script, no dynamic ability. It simply takes every image and squeezes them down to a specified width and height, and saves them as a new file.

I've read a little and probably can figure out the first part of my problem by using the getimagesize() function to get and challenge the image width being uploaded, but how exactly would i proportionately resize the height?

In a simple case, I could do start like this I suppose:


$dimensions = getimagesize($_FILES['myfile']);
$width = $dimensions[0];

if($width >= 501) {
    // create new file and set new width, but how to proportionately bring in the height too??


Any ideas?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users