Jump to content

Resizing an image using imagemagick


Giddy Rob

Recommended Posts

Hi,

 

I am a little stuck as I need to resize an image then get the width and height for a record in my database.

 

What I am basically trying to do is have a set of three constraints for the size or a custom size the user can set. For example if one option says"400 height || 400 width" then the width or the height will be set to a maximum of 400px, depending on the which is the largest (keeping aspect ratio). The custom just allows them to set the width and height themselves.

 

It was previously done with this command below, but the system has now moved servers so it doesn't work anymore as I don't think I have permission to use the system call.

 

   if ($_POST['picsize'] == 'S') {$_POST['maxwidth']=100;$_POST['maxheight']=100;}
   if ($_POST['picsize'] == 'M') {$_POST['maxwidth']=250;$_POST['maxheight']=250;}
   if ($_POST['picsize'] == 'L') {$_POST['maxwidth']=400;$_POST['maxheight']=400;}
   if ($_POST['maxwidth'] > 0 && $_POST['maxheight'] > 0) {
    system("/usr/local/bin/convert -quality 80 -thumbnail {$_POST['maxwidth']}x{$_POST['maxheight']}\\> \"{$_FILES['ins_image']['tmp_name']}\" \"../news_images/{$_FILES['ins_image']['name']}\"");
}

 

I would like to do this with imagemagick if possible.

 

Any help would be great :)

 

Cheers in advance :)

 

Rob Shillito

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.