Giter VIP home page Giter VIP logo

willow's Introduction

https://travis-ci.org/wagtail/Willow.svg?branch=master

Willow image library

A wrapper that combines the functionality of multiple Python image libraries into one API.

Documentation

Overview

Willow is a simple image library that combines the APIs of Pillow, Wand and OpenCV. It converts the image between the libraries when necessary.

Willow currently has basic resize and crop operations, face and feature detection and animated GIF support. New operations and library integrations can also be easily implemented.

It is written in pure-Python (versions 2.7, 3.3, 3.4, 3.5 and 3.6 are supported)

Examples

Resizing an image

from willow.image import Image

f = open('test.png', 'rb')
img = Image.open(f)

# Resize the image to 100x100 pixels
img = img.resize((100, 100))

# Save it
with open('test_thumbnail.png', 'wb') as out:
    img.save_as_png(out)

This will open the image file with Pillow or Wand (if Pillow is unavailable).

It will then resize it to 100x100 pixels and save it back out as a PNG file.

Detecting faces

from willow.image import Image

f = open('photo.png', 'rb')
img = Image.open(f)

# Find faces
faces = img.detect_faces()

Like above, the image file will be loaded with either Pillow or Wand.

As neither Pillow nor Wand support detecting faces, Willow would automatically convert the image to OpenCV and use that to perform the detection.

Available operations

Documentation

Operation Pillow Wand OpenCV
get_size()
get_frame_count() ✓** ✓**
resize(size)  
crop(rect)  
rotate(angle)  
set_background_color_rgb(color)  
auto_orient()  
save_as_jpeg(file, quality)  
save_as_png(file)  
save_as_gif(file)  
save_as_webp(file, quality)  
has_alpha() ✓*
has_animation() ✓* ✓*
get_pillow_image()    
get_wand_image()    
detect_features()    
detect_faces(cascade_filename)    

* Always returns False ** Always returns 1

willow's People

Contributors

findsje avatar florianludwig avatar frmdstryr avatar gasman avatar item4 avatar kaedroho avatar maiksprenger avatar mans0954 avatar marksteve avatar mozgsml avatar mrchrisadams avatar nealtodd avatar sannykr avatar tomasolander avatar trumpet2012 avatar wgiddens avatar zerolab avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.