Image size/ratio question |
Image size/ratio question |
CharlesEF |
Sep 17 2013, 09:40 PM
Post
#1
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Hi All,
I'm looking for advise on how to handle the next phase of my project. I'm working with images (lets say country flags) and I have 1 main image, about 180 x 100. Not all flags are the same size and some flags have a different ratio when compared to other flags (some are wider, some are higher). 1. If I want to display a smaller version of a flag must I generate an image with the size I want OR can I just write the <img> tag with the size I want? 2. How can I know what size the original image is so I can write the <img> tag in a size that maintains the flag ratio? Is there some way to read this information off the server or do I have to maintain a list of each image size? I will be using .png when I can otherwise I will use .gif format. Or, am I totally off base with my idea? Can anyone suggest a better way? Thanks for any ideas, Charles |
Brian Chandler |
Sep 17 2013, 10:51 PM
Post
#2
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
1. If I want to display a smaller version of a flag must I generate an image with the size I want OR can I just write the <img> tag with the size I want? Assuming the images are fairly small to start with, you can just resize them (e.g.) to a standard height using CSS, and let the width adjust automatically. Of course if they are 5MB files, you need to resize them to thumbnails. QUOTE 2. How can I know what size the original image is so I can write the <img> tag in a size that maintains the flag ratio? Is there some way to read this information off the server or do I have to maintain a list of each image size? You can get the pixel dimensions easily in PHP (forget the details), but as above, in general there is no need to do this. QUOTE I will be using .png when I can otherwise I will use .gif format. Or, am I totally off base with my idea? Can anyone suggest a better way? Either should be fine... In the old days I used PaintShopPro, which made it very easy with gifs to adjust exactly the colour palette being used. Now it seems to be much harder to see what's going on, but I suppose that's called "progress". |
CharlesEF |
Sep 18 2013, 10:49 AM
Post
#3
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
Thanks for the information, I have found the php getimagesize() command which should do what I need. The actual file size is small, average of about 250KB.
Thanks for the help, Charles |
Brian Chandler |
Sep 18 2013, 10:34 PM
Post
#4
|
Jocular coder Group: Members Posts: 2,460 Joined: 31-August 06 Member No.: 43 |
Thanks for the information, I have found the php getimagesize() command which should do what I need. The actual file size is small, average of about 250KB. But a small flag of Japan (for example) ought to fit in around 200 bytes: see the top of this page... http://imaginatorium.org/shop/shop.htm So why do modern systems take 1000 times as much space? Really, quite some progress... |
CharlesEF |
Sep 19 2013, 01:23 AM
Post
#5
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
I might be wrong but I start with a large version of the flag and then reduce it to fit in the space I want. I think I retain as much of the detail as I can this way.
At least that's what I think. Also, I might have overstated the file size since I was not using my laptop at the time and could not check the actual sizes. |
Lo-Fi Version | Time is now: 26th May 2024 - 09:05 PM |