UP: 35d, 12h, 46m | CPU: 40% | MEM: 5282MB of 8191MB used
 BetaArchive FAQ  | Search
 {The community for beta collectors}

### 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

 Page 1 of 1 [ 6 posts ]
Author Message
 Post subject: Image uploader - can anyone help?        Posted: Fri Mar 14, 2008 11:23 pm

Joined
Tue Oct 23, 2007 11:21 pm

Posts
596
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.

Top
 Post subject:        Posted: Sat Mar 15, 2008 7:14 am

Joined
Fri Aug 18, 2006 12:05 pm

Posts
698

Location
Or-stray-liagh
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

Top
 Post subject:        Posted: Sat Mar 15, 2008 12:55 pm

Joined
Fri Aug 18, 2006 11:47 am

Posts
12600

Location
United Kingdom

Favourite OS
Windows 10
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...

Top
 Post subject:        Posted: Sat Mar 15, 2008 3:45 pm

Joined
Fri Aug 18, 2006 12:05 pm

Posts
698

Location
Or-stray-liagh
Andy wrote:
I think my brain just went into spasm...

It shouldn't, it's noob maths.

_________________
pr0gram the pr0grammer
BetaArchive retiree | OSBA Expat

Top
 Post subject:        Posted: Sat Mar 15, 2008 7:07 pm

Joined
Fri Aug 18, 2006 11:47 am

Posts
12600

Location
United Kingdom

Favourite OS
Windows 10
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.

Top
 Post subject:        Posted: Sat Mar 15, 2008 9:14 pm

Joined
Tue Oct 23, 2007 11:21 pm

Posts
596
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...

Top
 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

#### Who is online

Users browsing this forum: No registered users and 5 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

 Jump to:  Select a forum ------------------ Notices    Forum Rules [READ BEFORE POSTING]    Announcements    News and Releases General Chat    General Discussion Microsoft    DOS to Windows 3.xx    Windows 9x, ME    Windows 2000, NT, XP    Windows Vista, 7, 8.x, 10    Windows Phone Apple    Mac OS    Mac OS X    iOS Other    Other Operating Systems    Android/Google Operating Systems Applications and Games    Applications    Games Servers    Download Requests/Offers    BetaArchive FTP Server    Servers Discussion Gratuity Forums    Donators Discussion Forum    VIP Discussion (Invite Only) General and Site Discussion    Tutorials and Guides    Off Topic Discussions    Site Feedback and Support

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.