To minimize our total page sizes we've found it useful to force all images resized by this module into jpegs regardless of the original file format. With the images our users are uploading it easily saves a couple of hundred KiB going from png to jpg and isn't an appreciable loss of quality beyond what has already occurred in the scaling.

CommentFileSizeAuthor
#1 force_jpg-1557758-1.patch1016 bytespizzapotamus

Comments

pizzapotamus’s picture

Status: Active » Needs work
StatusFileSize
new1016 bytes

The very minor change we're using although I could see it needing to be an optional feature.

quicksketch’s picture

This patch doesn't actually change the format of images, it just changes the extension.

UPDATE: Oh, nope looks like I'm mistaken. http://api.drupal.org/image_gd_save will indeed convert an image based on its name alone. Not sure about this as an option personally.

pizzapotamus’s picture

That's what I would have thought except when I didn't immediately see anything setting the image format in the module code I figured what the heck it's quick and easy to see if it just goes based on the extension and on our server it does....
The following file was generated with just the above patch
http://www.austinquinceanera.com/sites/default/files/resize/attach/lagli... and the original image was
http://www.austinquinceanera.com/sites/default/files/attach/laglitter-11... Based on the file sizes and more importantly the magic numbers(as read by file) it's clearly changed from png to jpeg

pizzapotamus’s picture

For our usage going to jpeg is keeping in line with what I see as the main reason for the module, using the "right" image instead of whatever the user has uploaded and keeping bandwidth down. In our case the user simply can not or will not be bothered to do any manual image manipulation simply uploading the images in whatever size and format they come, if we could rely on them uploading images in the optimal format we also probably could rely on them using any of the other tools we'd previously provided for image resizing. If this module didn't already exist(thankfully it does) the input filter I'd currently be writing would have ended up defaulting to jpeg.

It's something I'd be willing to write a proper patch for with an interface but wanted to see if said patch would be welcome first.