Commits

Bertrand Bordage  committed bd8a720

Uses transparent instead of black padding.

  • Participants
  • Parent commits 8c329d4

Comments (0)

Files changed (1)

File cmsplugin_nivoslider/thumbnail_processors.py

 # Solution found there:
 # http://stackoverflow.com/questions/11960079/padded-fit-with-easy-thumbnails
 
-import Image
+import ImageChops
+
 
 def pad_image(image, **kwargs):
     'Pad an image to make it the same aspect ratio of the desired thumbnail.'
         return image
 
     try:
-        # Black background
-        new_image = image.resize(new_image_size)
-        new_image.paste((0, 0, 0, 0))
-
-        new_image.paste(image, (left, top))
+        # Converts the image to add an alpha layer.
+        image = image.convert('RGBA')
+        # Resizes the image.
+        image = image.crop((0, 0, new_image_size[0], new_image_size[1]))
+        # Adds an offset to center the image.
+        new_image = ImageChops.offset(image, left, top)
 
         return new_image
     except: