Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
Fixing Images Uploaded in Python Webapps
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

Fixing Images Uploaded in Python Webapps

simdiasimdia Member
edited November 2016 in Tutorials

This a Python function method to “fix” images uploaded by webapp users. By fix, we mean,

Correct the image orientation (a somewhat nasty issue concerning JPEGs taken by cell phone cameras)
Strip the image of everything but its basic data (EXIF tags, gif animations, etc.)
Optionally restrict the width and/or height of the image, which is proportionally downsized to fit the tighter constraint using a high-quality downsampling algorithm

Usage documentation and an example are provided. You’ll need to install Pillow (python image library). Be sure to first install the external libraries to support additional image formats, etc. (don’t worry if they don’t all install successfully). See the Pillow Installation Instructions.

This code is free to use for any purpose.

Code: http://pastebin.com/yqGbU966

Sign In or Register to comment.