Image uploader - can anyone help?

Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it
Forum rules
Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it
Post Reply
RichardG867
FTP Access
Posts: 596
Joined: Tue Oct 23, 2007 11:21 pm

Image uploader - can anyone help?

Post by RichardG867 »

I'm creating an image uploader using PHP and GD, but I only get fixed size thumbnails. Question: how can I make dynamic size thumbnails (like BA ones)?

PS: I don't want to transform this question on my third unanswered on programming support.

pr0gram the pr0grammer
Donator
Posts: 698
Joined: Fri Aug 18, 2006 12:05 pm
Location: Or-stray-liagh

Post by pr0gram the pr0grammer »

It's not too hard to calculate your thumbnail size from your original image size. Let's say your original is AxB, and you want the thumbnail to be at the maximum 160x160. The aspect ratio of the original image is A/B. Therefore, if your thumbnail is XxY, then X/Y = A/B. If X = 160, then Y = A/(B*160). If Y is < 160, then X and Y are your thumbnail dimensions. If Y is > 160, then let Y = 160, and calculate X by going X = 160*A/B, and this will be your thumbnail size. When you go to create the new thumbnail image in GD, set your width & height to these calculated X and Y values.
pr0gram the pr0grammer
BetaArchive retiree | OSBA Expat

Andy
User avatar
Administrator
Posts: 12622
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Post by Andy »

pr0gram the pr0grammer wrote:It's not too hard to calculate your thumbnail size from your original image size. Let's say your original is AxB, and you want the thumbnail to be at the maximum 160x160. The aspect ratio of the original image is A/B. Therefore, if your thumbnail is XxY, then X/Y = A/B. If X = 160, then Y = A/(B*160). If Y is <160> 160, then let Y = 160, and calculate X by going X = 160*A/B, and this will be your thumbnail size. When you go to create the new thumbnail image in GD, set your width & height to these calculated X and Y values.
I think my brain just went into spasm...

pr0gram the pr0grammer
Donator
Posts: 698
Joined: Fri Aug 18, 2006 12:05 pm
Location: Or-stray-liagh

Post by pr0gram the pr0grammer »

Andy wrote: I think my brain just went into spasm...
It shouldn't, it's noob maths.
pr0gram the pr0grammer
BetaArchive retiree | OSBA Expat

Andy
User avatar
Administrator
Posts: 12622
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Post by Andy »

pr0gram the pr0grammer wrote:
Andy wrote: I think my brain just went into spasm...
It shouldn't, it's noob maths.
Yeah I should know as well, I had the same issue when doing BA's image uploader.

RichardG867
FTP Access
Posts: 596
Joined: Tue Oct 23, 2007 11:21 pm

Post by RichardG867 »

Thanks.

I can't do it now, I'm surfing in a Windows 2000 virtual machine right now.
The virtual machine contains PHP 5 and IIS 5 inside, but...

Post Reply