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

Format Preservation with minimal alterations #135

Closed
wants to merge 9 commits into from

Conversation

pygeek
Copy link
Contributor

@pygeek pygeek commented Dec 11, 2012

This pull request adds the ability to preserve the file type of the image being converted into a thumbnail depending on the boolean settings.THUMBNAIL_PRESERVE_FORMAT, which is set to False by default.

This pull request gracefully degrades and defaults to using settings.THUMBNAIL_FORMAT. Applications that currently use sorl should not notice any difference in functionality unless settings.THUMBNAIL_PRESERVE_FORMAT is set explicitly set to True.

This pull request is desirable for anyone developing a medium scale application that relies on sorl, as the dilemma of preserving transparent PNGs as PNGs while optimizing JPGs arises quickly. I have several colleagues who have written this functionality into their application or have created their own backend to handle this case; I feel this is basic functionality that should be included in the sorl repo.

Thank You and Best Regards,
~pygeek

Boolean to preserve thumbnail format added. Defaulted to False
There are instances where file_type preservation is desired at the base level.
I, therefore, added ability to preserve file type in thumbnail if settings.THUMBNAIL_PRESERVE_FORMAT = True; it is set to False by default.
@thenewguy
Copy link

I think this is a good idea. I think it would be better to test for image type instead of checking the file extension though.

There is a python module for testing image type: http://docs.python.org/2/library/imghdr.html. The convert engines could also provide a method to test for image types if they could do it faster, more reliably, or better in some way.

@andreyshipilov
Copy link

Yes. It should be the default option.

@ghost ghost assigned mariocesar Nov 12, 2013
@mariocesar
Copy link
Collaborator

@pygeek nice! Right now is not possible to automerge this, would you please review your pull request against the current master branch? I will be glad to merge this ASAP

@mariocesar
Copy link
Collaborator

This is fixed on the master branch, thanks :)

@mariocesar mariocesar closed this Feb 13, 2014
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

4 participants