Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround to prevent thumbnail creation for GIFs #505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wfehr
Copy link

@wfehr wfehr commented Oct 22, 2018

Since a solution to preserve animations on GIFs is a bit tricky I made a little workaround to prevent thumbnail creaton for GIFs.

Issues for this problem: #184 and #217

@@ -113,7 +113,10 @@ def render(self, context):
return self.bail_out(context)

try:
thumbnail = get_thumbnailer(source).get_thumbnail(opts)
if settings.THUMBNAIL_PREVENT_GIF_CONVERT and '.gif' in source.url:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather use

Suggested change
if settings.THUMBNAIL_PREVENT_GIF_CONVERT and '.gif' in source.url:
bits = os.path.splitext(source.url)
if settings.THUMBNAIL_PREVENT_GIF_CONVERT and bits[1] == '.gif':

to explicitly state what's the intention.

@wfehr
Copy link
Author

wfehr commented Oct 23, 2018

Thanks for the quick review! I just pushed it with that changes.

Edit: Forgot about the tests, trying to fix that.
Edit2: I changed the piece of code so tests are running again.
Don't really understand why this

117             bits = os.path.splitext(getattr(source, 'url', source.name))
118             if settings.THUMBNAIL_PREVENT_GIF_CONVERT and bits[1] == '.gif':

is a reason for some tests to fail.

@wfehr
Copy link
Author

wfehr commented Jul 25, 2019

Any news on a possible release date?

@jrief
Copy link
Collaborator

jrief commented Jul 25, 2019

You wrote:

Since a solution to preserve animations on GIFs is a bit tricky I made a little workaround to prevent thumbnail creation for GIFs.

Is there any way to detect, if a gif has animations? What kind of errors happen, if Pillow creates a thumbnail from an animated gif.

@wfehr
Copy link
Author

wfehr commented Jul 26, 2019

Is there any way to detect, if a gif has animations? What kind of errors happen, if Pillow creates a thumbnail from an animated gif.

Sorry for the misunderstanding: I didn't really try out how to solve the problem myself. I wrote this based on the comments in the above mentioned issues.
What I meant is, if this workaround is going to be released?

@jrief
Copy link
Collaborator

jrief commented Jul 26, 2019

For me it seems to solve a problem, which is too specific to one use-case.
If this is really a problem for animated GIFs, then I would apply it only this class of images.

@Akiat
Copy link

Akiat commented Jan 18, 2021

Really interested by this PR. I need to preserve GIF animation and it would be great to have this in the release.

Edit: I tried it, but the animation isn't preserved in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants