Login

Tag "image"

Snippet List

simple text image view

**Credit goes to** [Andrew Gwozdziewycz](http://www.23excuses.com/2006/Jun/30/simple-django-view-for-dynamic-text-replacement/) and [Jacob Kaplan-Moss](http://www.jacobian.org/writing/2006/jun/30/improved-text-image-view/) This is basically their code. Only differences: * orientation can be customized * size can be customized * GIF-Image with transparency is created Note: Because of the minimum palette that's used, the font isn't antialiased/smoothened. My url for this view looks like so: (r'^img/(?P<fontalias>\w+)/(?P<orientation>(normal|left|right))/$', 'view.text_to_image')

  • text
  • image
  • text-image-view
Read More

Function to create resized versions of an image from a URL and saving it to a local path

This is a really useful function I used to create the resized preview images you can see on the [homepage of my site](http://www.obeattie.com/). Basically, it takes the original URL of an image on the internet, creates a resized version of that image by fitting it into the constraints specified (doesn't distort the image), and saves it to the MEDIA_ROOT with the filename you specify. For example, I use this by passing it the URL of a Flickr Image and letting it resize it to the required size, and then saving it to a local path. It then returns the local path to the image, should you need it. I however just construct a relative URL from the image_name and save that to the database. This way, it's easy to display this image. Hope it's useful!

  • image
  • pil
  • thumbnail
  • resize
Read More

Sharpening images

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.

  • image
  • pil
  • sharpen
  • thumbnail
Read More

64 snippets posted so far.