Login

Sharpening images

Author:
rajeshd
Posted:
February 28, 2007
Language:
Python
Version:
Pre .96
Tags:
image pil sharpen thumbnail
Score:
3 (after 3 ratings)

Returns a sharpened copy of an image.

Resizing down or thumbnailing your images with PIL.Image tends to make them blurry. I apply this snippet to such images in order to regain some sharpness.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from PIL import ImageEnhance

def _sharpen(image, sharpness=1.6):
    """
	Returns a sharpened copy of an image. 
	
	Resizing down or thumbnailing your images with PIL.Image tends to make them blurry. I apply this snippet to such images in order to regain some sharpness.
	"""
    sharpener = ImageEnhance.Sharpness(image)
    sharpened_image = sharpener.enhance(sharpness)
    return sharpened_image

More like this

  1. thumbnail an image by limodou 8 years, 5 months ago
  2. Admin Image Widget + easy-thumbnails by babu 4 years, 1 month ago
  3. Image Standarization by garcia_marc 7 years, 3 months ago
  4. Thumbnails in admin using django-thumbnails-works by dperetti 4 years, 7 months ago
  5. ImageField with specified maximum image size by virhilo 5 years, 4 months ago

Comments

Please login first before commenting.