Posted by: CharlesEF Sep 17 2013, 09:40 PM
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
Posted by: Brian Chandler Sep 17 2013, 10:51 PM
QUOTE(CharlesEF @ Sep 18 2013, 11:40 AM)
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".
Posted by: CharlesEF Sep 18 2013, 10:49 AM
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
Posted by: Brian Chandler Sep 18 2013, 10:34 PM
QUOTE(CharlesEF @ Sep 19 2013, 12:49 AM)
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...
Posted by: CharlesEF Sep 19 2013, 01:23 AM
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.