← 输入框|github.com|刷新
Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

File extensions in Cache (& via API) do not reflect the true file format #30

Open

Description

@bschollnick

Hey.

I am looking to use Python-thumbnails as a partial replacement for a thumbnail system that I was working on... But I've noticed an issue...

tnail = get_thumbnail(testfilename, '300x300', crop='center', force=True, format="PNG")

Does set the result file format to PNG, but the file extensions in the cache folder, is JPG.

tnail.extension
'jpg'

Is this intended? I'm using this in the basic python mode, without Django, etc.

Activity

  1. relekang commented on Oct 14, 2017

    @relekang
    Member

    Nice catch, this is most definitively a bug. I think I found the source: The Thumbnail model has hardcoded jpg as extension. Do you want to look into fixing it?

  2. bschollnick commented on Oct 27, 2017

    @bschollnick
    Author

    I don't see an easy way to do this as written in the code.

    The original filename is not send to the thumbnail object, so the only way I see to do that is to add something like:

    thumbnail = Thumbnail(thumbnail_name)
    thumbnail.fileext = os.path.splitext(original.file)[1][1:]
    if force or not thumbnail.exists:
    

    where:

    class Thumbnail(object):

    size = None, None
    image = None
    _url = None
    fileext = "jpg"
    
    @property
    def extension(self):
        return self.fileext
        #return 'jpg'
    

    But that's not elegant at all. But It works...

  3. relekang commented on Oct 27, 2017

    @relekang
    Member

    I think I figured something out, a most of the code for detecting image format was already in place but never called. I added extension as a required argument to the Thumbnail constructor.

    @bschollnick Does latest master work any better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions