View Full Version : Artwork Size (Was Re: DevelopmentProtocolandEtiquette)

Christopher Key
2006-04-11, 15:51
mwphoto wrote:
> I already developed this, I wasn't sure it was robust so I never
> submitted the patch, and I'm a little uncomfortable about the variety
> of image naming options that aren't handled that cleanly.
> Anyway Here's the patch - it works for me . . . (it patches
> server\Slim\Web\HTTP.pm)
> (request thumb_100x100.jpg) for 100x100 image size
> +-------------------------------------------------------------------+
>> Filename: Artwork.patch |
>> Download:
>> http://forums.slimdevices.com/attachment.php?attachmentid=1179|
> +-------------------------------------------------------------------+

Thanks very much, I've had a play and extended this somewhat, and would
appreciate some feedback on how people feel this should most usefully work.

As it stands at present, both thumbnails and covers are handled. The only
difference between the handling of thumbnails and covers is that when no
size is specified, a thumb takes the size 'thumbSize' square, whereas a
cover takes the size of the original image. If the image is being resized,
it is now possible to specify whether to stretch the image, or to maintain
the aspect ratio of the original by padding or cropping. If no option is
specified, then the default is to stretch it. In order to maintain
compatibility with how the system operated previously, if no resizing method
is specified then images won't be stretched to a larger size. Finally,
image format is maintained to a limited extent; if the source image is a png
and GD will handle it, then a png is outputted, otherwise the output is a

I think this meets a sensible set of criteria. It doesn't change the
behaviour of the previous code significantly, with the exception of
outputting a png image on occasion, and only where the cover would have been
a png. The size of the images are ultimately decided by the skin, although
the resizing is done on the server giving better quality images and possibly
faster rendering on slower clients. Images with unusual aspect ratios are
handled sensibly in a skin determined fashion.

Some example filenames are as follows:

/thumb.jpg - Returns an image stretched to the server default thumbnail size
/thumb_c.jpg - Returns an image cropped to the server default thumbnail size
/thumb_p.jpg - Return an image padded to the server default thumbnail size
/cover_200x200.jpg - Returns an image stretched down to 200x200, or the
original if it was smaller.
/cover_200x200_s.jpg - Returns an image stretched down to 200x200

If everyone's happy with this functionality, I'll commit it into the trunk
for testing.

Chris Key