Jump to content

resizing images on the fly


graham23s

Recommended Posts

Hi Guys,

 

what im trying to do is get random inages from mysql and display them in like a "random profile" box, but i was trying to keep them all roughly the same size, so basically grab them from mysql and:

 

<img src="images/image1.jp2" height="$height" width="$width">

 

so basically it just displays them in the correct ration WITHOUT saving them

 

is this possible at all?

 

thanks guys

 

Graham

Link to comment
Share on other sites

I do this on my server, but since its my server I just use image magick's convert command.  My code looks like this:

 

	
function imgResize($img)
{
exec('convert -size 125x125 '.$img.' -resize 125x125 '.$img);
return true;
}

 

Where image is the full path to the file.

 

 

Link to comment
Share on other sites

I wouldn't be the right person to ask if it is better or worse, but its obviously easier and there aren't really any downsides.  The portion after the -resize argument is where you are telling the command to save the file.  In the example I gave, I am just over writing the existing file.

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.