Resizing pictures - constraining proportions

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
slindstr
Forum Newbie
Posts: 6
Joined: Thu Aug 04, 2005 11:01 pm

Resizing pictures - constraining proportions

Post by slindstr »

Hello,

I was hoping someone could help me find a solution to my problem. I need to display about 71 pictures of all different dimensions on a web page. I plan on using a loop to display them but I need to resize them and constrain the proportions of each picture at the same time. Any ideas?

Thanks
Steve
User avatar
William
Forum Contributor
Posts: 332
Joined: Sat Oct 25, 2003 4:03 am
Location: New York City

Post by William »

Use html and add width='' or height='' just 1 of them to resize to the height you want. Most of the time sence you resize one size it will automaticly do the other for you. But if you want to get more advanced you could use PHP to get the sizes and use math to fix it... But HTML is way easier.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use a resizing function, such as one posted in the Code Snippets board (here) while looping. One thing though, resizing that many images at one time (each time the script is run) will eat the processor and make the page run like molasses uphill in a Canadian "breeze."

I'd suggest resizing the images before hand and storing the results, or resizing only when necessary (can be a bit more advanced/involved).
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

William wrote:Use html and add width='' or height='' just 1 of them to resize to the height you want. Most of the time sence you resize one size it will automaticly do the other for you. But if you want to get more advanced you could use PHP to get the sizes and use math to fix it... But HTML is way easier.
Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.. :wink:

Seriously, that's the worst way of doing thumbnails ever. Use GD. Search for "php thumbnail" on here to get examples of code.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

If I could figure out how to do stuff on the new OS I'd post my thumbnail script, revised edition :P perhaps tommorrow...err I mean later today when I wake up
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
slindstr
Forum Newbie
Posts: 6
Joined: Thu Aug 04, 2005 11:01 pm

Thanks

Post by slindstr »

Thanks for all of your replies - I appreciciate it. I did find this GD tutorial on the web which seems to be pretty alright:

http://www.tutorialized.com/tutorial/Th ... in-PHP/788

I'll give it a try later today

Thanks again
Steve[/url]
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

that code looks pretty good.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Just adding some more thoughts.
Do please have in mind that resizing on the fly is, as mentioned, memory/cpu consuming. If the page is under alot of stress you should consider using GD as a means to create physical thumbnails instead of dynamic (as shown in the example url above).

If it's possible to do for your solution that is. ;)
User avatar
slindstr
Forum Newbie
Posts: 6
Joined: Thu Aug 04, 2005 11:01 pm

Post by slindstr »

What would be the best way to create the physical thumbnails? I don't think I fully get it... (sorry I'm still fairly new to PHP)

Thanks
Steve
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you have the realizing function write the image stream to a file instead of the output stream. Have a look at imageJpeg().
User avatar
slindstr
Forum Newbie
Posts: 6
Joined: Thu Aug 04, 2005 11:01 pm

Post by slindstr »

So would/could it be one file containing all of the image data, or a file for every image that needs to be resized?

Also would I just make a php page that would not be seen by the public that I would run once and have all of the data be put into the file(s), THEN when the public goes to view the pictures it just reads the file(s) containing the data?

Thanks
Steve
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What I do is:
  1. generate seperate files for each thumb
  2. the thumb creator is apart of the script that displays the gallery
  3. the generated thumb is cached in a seperate location (if another thumb does not exist with the main image).
  4. the thumb creator looks at the thumb's time and the original image's. If the original image is newer or doesn't have a thumb, it generates one. Otherwise, it ignores the image.
This will make the initial page view sluggish as all the thumbs are generated, but after that, the page is quite fast.
Post Reply