easy-thumbnails icon indicating copy to clipboard operation
easy-thumbnails copied to clipboard

Keep original image if size matches

Open satyrius opened this issue 10 years ago • 4 comments

For example I have the following settings for thumbnailer

    THUMBNAIL_ALIASES = {
        '': {
            'banner': {'size': (730, 480), 'crop': False},
        },
    }

I want to keep source file unchanged in case its dimensions match the thumb size. Is it possible?

satyrius avatar Jan 27 '15 15:01 satyrius

Just for curiosity, why?

Note that easy_thumbnails can apply all sorts of filter, not only an image resizer. Therefore having the exact same target as the source image is a rather rare edge case. It would be quite an overhead to then search for that image in filer_images rather that filer_images_thumbnails.

Why not just referring to the image directly?

jrief avatar Jan 27 '15 17:01 jrief

@jrief My case: I have a banners placeholder, the moderators can use to upload banner images. Sometimes they use banners created by designer and they have accurate size and optimised quality. But sometimes they just want to upload any image and I have to fit it to banner container box. Thats why I want to skip thumbnailer and use original image.

satyrius avatar Jan 27 '15 18:01 satyrius

In my opinion, skipping the resizing when the image is already the same size might look like a micro-optimization, but in reality it will allow you to preserve the quality of the original image. With PNGs it does not do a difference, but re-saving a JPG might blow away the quality. I would propose an additional option that allows skipping the scaling algorithm if the image size is the same as the original; it would instead simply copy the original file verbatim. Something like skip_if_same_size=False. Making it optional is a good idea since the thumbnail library can not only be used to scale image, but also to reduce the file size, i.e. I might want to save my thumbnails on purpose with quality=70; in this case I would not like to re-use the original image if its quality is set to 99. Regarding the thumbnail storage folder, I would not think that copying the original to the thumbnail folder is such a big deal; disk space is cheap, and if you did not have the option enabled you would also end up with a thumbnail of the same size in the thumbnails folder.

sebleblanc avatar Apr 14 '15 19:04 sebleblanc

+1, this is stopping me from using this package right now.

pwmarcz avatar Apr 23 '15 16:04 pwmarcz