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
https://forums.phpfreaks.com/topic/77508-resizing-images-on-the-fly/
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.

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.