Wednesday, 29 July 2009

Fix for Image Uploads

Just a quick note to let you know that i've uploaded some modified code to handle the cropping resizing of images when you update ships, captain profiles and society emblems.

All images go through a two step process when uploaded; first they are resized so that we can retain as much of them as possible, and then they are cropped - captains and society emblems are made 100x100 square, while ships are made 200x200 for the smaller images, and we try to make a nice larger image of 640x480. (Remember when your desktop was only that big? :-))

Anyway - There were a couple of problems with the code I had put together and I my tired brain couldn't work out where the mistake was. Firstly, by resizing images to width and then cropping to height, meant that different orientations of images that were of such a size that the first resize pass left them too small in one dimension, and the crop would then add a piece back onto the picture to make it the right size. This is now fixed in two ways; firstly, the resize pass works out what orientation your image is in and adjusts the way it resizes to suit, before cropping and leaving the right sized leftovers. For captains and societies, the resize is allowed to grow your image though that will result in loss of quality, so I recommend uploading ones of a size greater than required.

For ships, the solution has been to not allow the image to be 'grown' - if we can't attain 640 x 480, the system gets as close as it can without adding more onto the picture and we keep it at that. In all cases, cropping now keeps the centre of the image, rather than the top left, and discards the rest.

You'll also notice that ships get a banner at the bottom of their images; this is not for any copyright purposes because the images belong to the game, FLS and whoever modelled them. The banner is there in the hope that next time someone is googling for images of a sailing ship, these will appear, direct traffic to the website and in turn to the game, helping out our server populations :)

The banner was broken though - because if the image can't be made 640 wide, the right hand side was truncated. It looks messy and amateurish and doesn't help at all. A new banner only has content on the left side so should appear correctly in all cases.

Sorry for the boring theoretical image handling post, but I thought people might have noticed and wondered whats going on. New uploads will work better, old uploads will remain as they are - in time, i'm sure they will get replaced.

0 comments:

Post a Comment