Flag scaling and aspect ratios...
Country193
12-04-2006, 16:46
Hi everyone,
I was just looking at how the flags are displayed, and had an idea. At the moment we can all upload images up to 107x71 in size, but the HTML which displays them at full size doesn't specify the size so the browser gets to show them at the correct size. When the flag images are shown on a page which lists many countries, the HTML shows the same image but tells the browser to use the size 40x26. What this means is that I can upload a square flag which is say 71x71, but it will have it's aspect ratio changed so that it fits into a 40x26 box. This can easily be fixed by only using one of the height or width attributes in the HTML rather than both so that the browser will scale it proportionately. In the real world, different flags have different aspect ratios, so why can't we here? (Have a look at Switzerland (square) and Nepal (4:3) for example, and see here: http://flagspot.net/flags/faq2.html#prop )
Oh yeah, one more thing - why are we supposed to use JPEGs? GIF and PNG files work fine in IE and Firefox even though they are renamed with a .jpg extension. PNGs give good compression and are lossless unlike nasty artifact full JPEGs! The lossy JPEG compression algorithm is best suited for photos and doesn't make so much sense for flags.
Cheers!
The Most Glorious Hack
13-04-2006, 04:17
This can easily be fixed...Fixing implies that this isn't intentional. Having square flags or verticle flags on the regional and world displays will screw with the tables.
The lossy JPEG compression algorithm is best suited for photos and doesn't make so much sense for flags..png's suck. Furthermore, we're talking about very small files and small images. Considering real flags tend to be things like color bars, there's no problem with using .jpg's. The artifacts come in when people want to use non-flaglike images.
My flag is a .jpg and it looks just fine.
[violet]
13-04-2006, 08:57
Actually it was a pretty silly decision to use JPEGs. GIF or PNG would have been better. But it's not a big deal.
I'm not sure how the scaling idea would work. If we only specify height, couldn't someone upload a really, really wide flag and screw the page formatting? Or, if we specified width instead, a really tall flag?
Country193
13-04-2006, 21:19
Fixing implies that this isn't intentional.
Then why aren't the width and height attributes specified for the full side image? The text "2. about 107x71 pixels in size" on the "Create Your National Flag" page suggests the programmer did not want to enforce the aspect ratio of users' flags, but this is exactly what he has done when the flags are shown at the smaller size. There is a discrepancy here.
.png's suck. Furthermore, we're talking about very small files and small images. Considering real flags tend to be things like color bars, there's no problem with using .jpg's.
It's certainly less of a problem for GIFs and PNGs. Both can use Run Length Encoding (perfect for contiguous blocks of colour) whereas JPEGs don't.
Apart from for animations, PNGs are always better than GIFs as they support higher colour depth and have better compression rates (amongs other things like transparency). That said, both are far better than JPEGs for limited colour images (like flags!). JPEG stands for "Joint Photographic Experts Group", and that should give you an idea as to what this image format is optimised for.
']Actually it was a pretty silly decision to use JPEGs. GIF or PNG would have been better. But it's not a big deal.
Thanks for agreeing with me about JPEGs - I think it's pretty silly too!
Since you can currently use JPEGs, GIFs and PNGs, why not remove the "1. in JPEG (.jpg) format" text from the "Create Your National Flag" page and stop the backend renaming GIFs and PNGs with the ".jpg" extension?
']I'm not sure how the scaling idea would work. If we only specify height, couldn't someone upload a really, really wide flag and screw the page formatting? Or, if we specified width instead, a really tall flag?
Hmm, you have a point - I hadn't thought of users trying to be malicious (imagine flags of 107x1 or 1x71). I suppose the backend code could check that the aspect ratio of the uploaded flag is within a sensible range. That should prevent this problem.
What do you think?
The Most Glorious Hack
14-04-2006, 04:34
Then why aren't the width and height attributes specified for the full side image? The text "2. about 107x71 pixels in size" on the "Create Your National Flag" page suggests the programmer did not want to enforce the aspect ratio of users' flags, but this is exactly what he has done when the flags are shown at the smaller size. There is a discrepancy here.Compare the main nation page to the regional page. The main nation page isn't bound in a chart and has considerable more flex room, depending on the length of the name. The 107x71 'restriction' made more sense when the limit was 6kb, as it was harder to get a larger image inside the restrictions. It also gives people the ratio for when the flag is compressed. A flag with that ratio looks fine on the regional page, others get distorted.
Like I said, not compressing would break the regional/world page.