Page 1 of 1

GD

Posted: Thu May 28, 2009 9:44 pm
by Jim_Bo
Hi,

How can I alter the following code so I can resize the width making the heigh wild to keep the proportion?

Code: Select all

 
$Config_tbwidth_wide = 200;
$Config_tbheight_wide = 200;
 
$Config_tbwidth_tall = 200;
$Config_tbheight_tall = 200;
 

Thanks

Re: GD

Posted: Thu May 28, 2009 10:24 pm
by requinix
Here's an analogy of what you just did:
You just handed us a blank piece of paper and asked us how long ago the tree was cut down.

You have three options:
1. Post all the code that has to do with image resizing.
2. Explain what those variables mean.
3. Since you don't seem to understand PHP well, it's a good guess you didn't develop this yourself. Ask your question to the person who did, or tell us what library/code sample you downloaded.

Re: GD

Posted: Thu May 28, 2009 10:56 pm
by Jim_Bo
Wow.. they are simple variables defining the height and witdth to resize the images too... I was asuming a simple astrix used as a wild setting.

PS.. I like the way you assume I dont understand php well mate.

Re: GD

Posted: Fri May 29, 2009 2:50 am
by onion2k
Jim_Bo wrote:PS.. I like the way you assume I dont understand php well mate.
I thought it was quite a fair assumption given your question and further response.

You can't use a wildcard. You'll need to write some code to get the width and height of the image (using getimagesize()), then calculate the new size using a straightforward formula to maintain the aspect ratio.

Re: GD

Posted: Fri May 29, 2009 4:43 am
by McInfo
Algebra lesson:

To find the new height after resizing the width, use this formula:

Code: Select all

$new_height = $new_width * $old_height / $old_width;
Suppose you have an image whose width is 320 pixels and height is 240 pixels. You want to resize the width to 100 pixels. The new height will be 75 pixels.
Equivalent-Ratios.png
Equivalent-Ratios.png (3.72 KiB) Viewed 203 times
Edit: This post was recovered from search engine cache.

Re: GD

Posted: Sat May 30, 2009 6:21 pm
by Jim_Bo
Hi,

I have it solved, I allready new the information posted, I guess my question was bit lame in the way I asked.. I just assumed given it was GD and posted width and height variable it would make sence as I new was I was trying to acheive.

Small issue I still have is checking whether the form file feilds contain a file or not .. If any of the fields hold a file then exicute the code.

I thouhght something like

Code: Select all

 
if ($_FILES['image']['size'] > 0) {
 
Would do it, but the code seems to exicute even when the feilds dont contain any files. How would this be done?

Thanks