google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Prevent resizing if image is already at the right size #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
First, thanks for the great tool -- I scrapped my gallery implementation in
the favor of yours :)

(ver 0.5)

I just hit one issue -- if one requests size which is the same as original
image size image gets saved again in the cache which in the case of the
jpeg images cause additional loss of quality.

Quick fix is to add following after 'new_width, new_height =
photosize.size()' in create_size (models.py L220):

if (cur_width == new_width) and (cur_height == new_height):
# prevent resize if w/h are already right, just copy it with new name
    import shutil
    shutil.copy(self.get_image_filename(), getattr(self, "get_%s_path" %
photosize.name)())
    return

So original image is copied in the cache instead of re-saving.

(if needed I can re-submit this as a proper diff)

Original issue reported on code.google.com by djn...@gmail.com on 5 Dec 2007 at 3:12

GoogleCodeExporter commented 9 years ago
This is fixed in trunk (Rev 84). Thanks!

- Justin

Original comment by justin.d...@gmail.com on 8 Jan 2008 at 9:55