...

View Full Version : Looking for GDImage script...anyone know about this?



bowser1111
07-03-2007, 08:45 AM
Hi... I'm pulling my hair out trying to find a page I saw a while back and wasn't smart enough to put into my bookmarks...

It was a guy who had made a script using PHP and the GD library which took a group of images and calculated the best way to fit them into a single block.

For example if you have a bunch of random images with different dimensions, it will resize them to fit perfectly into a 500x500 square (etc). Does anyone have any idea what this is called or the page where I could find it??

Thank you...

timgolding
07-03-2007, 03:14 PM
I'll see if i can dig something up for you

timgolding
07-03-2007, 03:32 PM
This function will return an array of your dimensions that are in proportion and no sides greater than that passed to the function as the $new_h parameter


function get_dims($src_img,$new_h)
{
// A small function to ensure that the width and height of the thumbnails are no larger than 200px
$new_w=$new_h;
$size=getimagesize($src_img);
$old_x=$size[0];
$old_y=$size[1];
if ($old_x > $old_y)
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y)
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y)
{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$size[0]=$thumb_w;$size[1]=$thumb_h;

return $size;

}

To call this function simply use



$size=get_dims($img_link,500);


Now you have got your dimensions you can use phpThumb_1.7.4.zip I even hosted this for you to download http://cybadev.co.uk/phpThumb_1.7.4.zip

Once downloaded extract and put the whole folder in your document root
Then you can call to it like so



echo'
<img src="phpThumb.php?src='.$img_link.'&w='.$size[0].'&h='.$size[1].'" />';


for a more detailed demo of phpthumb use this link
http://phpthumb.sourceforge.net/

bowser1111
07-03-2007, 04:54 PM
Thank you for your help.

However, the script (program? I remember it had a name) I'm looking for doesn't use a set pixel value, it calculates that dynamically based on the best way that the images fit together... sort of like Tetris... if you can picture that...

I remember that the calculations were quite complicated. It wouldn't be something that could be easily duplicated.

timgolding
07-04-2007, 10:48 AM
I see. Probably quite tough but very possible. Let me know if you find it



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum