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

Use original file extension when creating thumbnails #528

Merged

Conversation

Projects
None yet
2 participants
@ajarocki
Copy link

commented Feb 26, 2019

Fixes #527

@noliveleger noliveleger self-requested a review Mar 15, 2019

@@ -35,7 +36,8 @@ def get_dimensions((width, height), longest_side):


def _save_thumbnails(image, path, size, suffix):
nm = NamedTemporaryFile(suffix='.%s' % settings.IMG_FILE_TYPE)
image_ext = os.path.splitext(path)[1]

This comment has been minimized.

Copy link
@noliveleger

noliveleger Mar 19, 2019

Contributor

Can you use image_ext = image.format?
Or even
image_ext = image.format if image.format else settings.IMG_FILE_TYPE

It avoids an extra import and extra dot in the nm.name.

This comment has been minimized.

Copy link
@ajarocki

ajarocki Mar 19, 2019

Author

Ok, changed to image.format. I thought at first this could cause some issues, given that for .jpg image image.format == "JPEG", but it's actually saved with proper extension.

Regarding:
image_ext = image.format if image.format else settings.IMG_FILE_TYPE
I'm guessing that image.format should never be empty or None. If it is then there are probably some other issues.

Finally, maybe settings.IMG_FILE_TYPE should be removed from settings, as this seems to be the only place that uses it?

This comment has been minimized.

Copy link
@noliveleger

noliveleger Mar 19, 2019

Contributor

Indeed

@ajarocki ajarocki force-pushed the qedsoftware:527-fix-thumbnails-file-type branch from 4376b88 to 7030f24 Mar 19, 2019

@noliveleger noliveleger merged commit a5af173 into kobotoolbox:master Mar 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.