The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Image size/ratio question
CharlesEF
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 17 2013, 10:51 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post 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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Sep 18 2013, 10:34 PM
Post #4


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 03:06 PM