Resizing pictures - constraining proportions
Moderator: General Moderators
Resizing pictures - constraining proportions
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
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
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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).
I'd suggest resizing the images before hand and storing the results, or resizing only when necessary (can be a bit more advanced/involved).
Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo..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.
Seriously, that's the worst way of doing thumbnails ever. Use GD. Search for "php thumbnail" on here to get examples of code.
If I could figure out how to do stuff on the new OS I'd post my thumbnail script, revised edition
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.
Thanks
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]
http://www.tutorialized.com/tutorial/Th ... in-PHP/788
I'll give it a try later today
Thanks again
Steve[/url]
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.
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.
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.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you have the realizing function write the image stream to a file instead of the output stream. Have a look at imageJpeg().
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
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
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
What I do is:
- generate seperate files for each thumb
- the thumb creator is apart of the script that displays the gallery
- the generated thumb is cached in a seperate location (if another thumb does not exist with the main image).
- 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.