Skip to content

Commit

Permalink
Convert image to JPEG colorspace and save with higher quality and pro…
Browse files Browse the repository at this point in the history
…gressive, bumped version
  • Loading branch information
saulshanabrook committed May 29, 2013
1 parent 0ea8d30 commit fca5785
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
v0.1.7, 04/18/13 -- Transform post save, addressed force_update error
v0.1.6, 04/18/13 -- Reasons why to use library added to readme, moved error handling transform function.
v0.1.8, 05/29/13 -- Convert image to JPEG colorspace and save with higher quality and progressive
v0.1.7, 05/29/13 -- Transform post save, addressed force_update error
v0.1.6, 05/29/13 -- Reasons why to use library added to readme, moved error handling transform function.
v0.1.5, 04/18/13 -- Check first if image exists, before deleting
v0.1.4, 04/18/13 -- Added support for non-image files
v0.1.3, 03/20/13 -- Added instruction to add to INSTALLED_APPS
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-simpleimages',
version='0.1.7',
version='0.1.8',
author='Saul Shanabrook',
author_email='s.shanabrook@gmail.com',
packages=['simpleimages', 'simpleimages.test'],
Expand Down
10 changes: 9 additions & 1 deletion simpleimages/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ def django_file_from_pil_image(transformed_pil_image, file_name):
'image is a {0}, not a PIL Image'.format(type(transformed_pil_image))
)
temp_io = StringIO()
transformed_pil_image.save(temp_io, format='JPEG')
if transformed_pil_image.mode not in ('L', 'RGB'):
transformed_pil_image = transformed_pil_image.convert("RGB")
transformed_pil_image.save(
temp_io,
format='JPEG',
optimize=True,
quality=85,
progressive=True
)
temp_io.seek(0)
django_file = InMemoryUploadedFile(
file=temp_io,
Expand Down

0 comments on commit fca5785

Please sign in to comment.