Browse Source

Fix bug in Palette mode not being supported in JPEG to convert to RGB before JPEG save.

tags/v0.5.2
Isaac Bythewood 12 years ago
parent
commit
ed4f308144
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      pinry/pins/models.py

+ 4
- 0
pinry/pins/models.py View File

@@ -31,6 +31,8 @@ class Pin(models.Model):
temp_img.write(urllib2.urlopen(self.url).read())
temp_img.flush()
image = Image.open(temp_img.name)
if image.mode != "RGB":
image = image.convert("RGB")
image.save(temp_img.name, 'JPEG')
self.image.save(''.join([hash_name, '.jpg']), File(temp_img))

@@ -45,6 +47,8 @@ class Pin(models.Model):
size = (int(prop*float(image.size[0])), int(prop*float(image.size[1])))
image.thumbnail(size, Image.ANTIALIAS)
temp_thumb = NamedTemporaryFile()
if image.mode != "RGB":
image = image.convert("RGB")
image.save(temp_thumb.name, 'JPEG')
self.thumbnail.save(''.join([hash_name, '.jpg']), File(temp_thumb))



Loading…
Cancel
Save