Last active
February 11, 2017 17:31
-
-
Save gengue/74ecc1792e3ca645f4f38f89469297e4 to your computer and use it in GitHub Desktop.
Unescape special chars in Django VersatileImage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3.5/versatileimagefield/datastructures/base.py | |
# -*- coding: utf-8 -*- | |
def retrieve_image(self, path_to_image): | |
"""Return a PIL Image instance stored at `path_to_image`.""" | |
from urllib.parse import unquote | |
image = self.storage.open(unquote(path_to_image), 'rb') | |
file_ext = path_to_image.rsplit('.')[-1] | |
image_format, mime_type = get_image_metadata_from_file_ext(file_ext) | |
return ( | |
Image.open(image), | |
file_ext, | |
image_format, | |
mime_type | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment