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.
You also need to sign up for an account at https://im2.io/register, providing your username to API calls (see usage)
Pip install:
pip install -e [email protected]:benscott/imageoptim.git#egg=imageoptim
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)