Jump to content

php upload, resizing issue


majocmatt

Recommended Posts

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:

[code]
<?php

$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??
}

?>
[/code]

Any ideas?
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.