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

Not uploading images with uppercase extension

Open kkoci opened this issue 10 years ago • 8 comments

Hi, I noticed I can't upload images with uppercase names, such as image.JPG , I confirmed that if I change it to image.jpg it gets uploaded.

Is there a workaround for this?

Am I missing something?

kkoci avatar Aug 13 '15 18:08 kkoci

So this is for a ThumbnailerField? And an ordinary FileField (or ImageField) works?

Can you define "can't upload" better - does it raise an exception [which one] or fail silently?

SmileyChris avatar Aug 14 '15 07:08 SmileyChris

Hi Chris,

In my case it is a ThumbnailerImageField and it just fails silently.

jkblgithub avatar Aug 14 '15 07:08 jkblgithub

@SmileyChris, is this not due to uppercase info not being processed, as you indicated here: https://github.com/SmileyChris/easy-thumbnails/issues/375#issuecomment-131002868?

Let's call the option ALIAS (uppercase options don't get put in prepared_options, which is a good thing)

jaddison avatar Aug 15 '15 07:08 jaddison

No, if an option name is completely uppercase, it is simply ignored when building the options for the namer. It's a totally different case.

SmileyChris avatar Aug 15 '15 10:08 SmileyChris

I am unable to reproduce this. I am using a ThumbnailerImageField as well, with Pillow 2.9.0.

@kkoci - can you share your OS, Django, easy_thumbnails, PIL/Pillow versions and easy_thumbnails-specific options you may have in your settings.py? It should make it easier to reproduce.

jaddison avatar Aug 16 '15 08:08 jaddison

@jaddison Info requested is listed below. Please note that the upload fails on both dev and production setups. Thanks for your help.

Pillow==2.7.0 Django==1.7.5 easy-thumbnails==2.2 Dev: OS X Yosemite Production: Ubuntu 14.04 x64 settings.py

THUMBNAIL_ALIASES = {
    'directory.File': {
        'thumbnail': {'size': (500, 360), 'crop': True, 'upscale':True},
    },
}
THUMBNAIL_NAMER = 'pony.utils.thumbnail_namer'`

pony.utils.thumbnail_namer

    def thumbnail_namer(thumbnailer, prepared_options, source_filename, thumbnail_extension, **kwargs):
    options = kwargs.get('thumbnail_options','default value')

    size = options.get('size','default value')
    crop = options.get('crop', False)
    # Test to see if this is the resize for the alias
    if 500 in size:
        new_name = source_filename
        suffix = '_medium.' +thumbnail_extension;
        new_name = new_name.replace(('.' +thumbnail_extension), suffix)
        return new_name
    return source_filename

jkblgithub avatar Aug 17 '15 05:08 jkblgithub

For the sake of ruling things out, can you upgrade your Pillow and easy_thumbnails to the latest versions and try again? Assuming pip-installed packages:

pip install -U easy_thumbnails pillow

As an aside, after seeing your custom thumbnail namer, you might be interested in my pull request at #380 that adds an 'alias' namer - it uses the appropriate alias name from your THUMBNAIL_ALIASES setting. Hopefully it gets merged soon.

jaddison avatar Aug 17 '15 08:08 jaddison

@jaddison Hi James, Pillow was upgraded to 2.9.0 and django to 1.8.3 but unfortunately the issue still persists. Looking forward to using your new alias namer!

jkblgithub avatar Aug 17 '15 08:08 jkblgithub