Skip to content

benscott/imageoptim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ImageOptim

Python library for accessing the Image Optim API

"Web service for image compression. Easily resize and optimize images on your server."

Supports image resizing to power of 2 dimensions, for optimal use with THREE.WebGLRenderer.

Requirements

You also need to sign up for an account at https://im2.io/register, providing your username to API calls (see usage)

Installation

Pip install:

pip install -e git+git@github.com:benscott/imageoptim.git#egg=imageoptim

Usage

Optimize an image

api = ImageOptim(USERNAME);
img = api.image_from_file_path(file_path)
img.save(NEW_FILE)

Upscale & optimize an image

api = ImageOptimAPI(USERNAME);
img = api.image_from_file_path(file_path, {'size': '8192x4096', 'fit': True})
img.save(NEW_FILE)

ImageOptim API options can be passsed in as a dict of attribute:value. If an attribute requires no value (e.g. fit), set value to True. See API Documentation for details of API options.

Resize an image to power of 2 (optimised for THREE.WebGLRenderer)

api = ImageOptimAPI(USERNAME);
img = api.image_from_file_path(file_path, resize_pow2=True)
img.save(NEW_FILE)

You can also use a callback (for async stuff)

image_optim = ImageOptim()

def done(results):
    print(results)

image_optim.optimize('/path/to/image.jpg', done)

About

Python library for accessing Image Optim API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages