Giter Site home page Giter Site logo

aviaryfxpython's Introduction

Aviary Effects API Python Library

Introduction

A library for the Aviary Effects API written in Python.

Build and Install

  1. Download the latest AviaryFX Python Library
  2. Extract and run the following commands in the setup folder:
$ python setup.py build 
$ python setup.py install

Test

To test run the following command in the example/cgi-bin folder. This will run the methods and print the output to the terminal window.

$ python test.py

Instantiate an AviaryFX object

The Aviary Effects API is exposed via the AviaryFX class.

To create an instance of the class with your API key and API secret:

from AviaryFX import AviaryFX
API_KEY = "aviarytest"
API_SECRET = "aviarytestsecret"
aviaryfx = AviaryFX(API_KEY, API_SECRET)

Get a list of filters

The getFilters() method returns a list of FilterInfo objects that contain the label, uid and description for each filter. These can be used to render images.

To get the list of filters:

filters = aviaryfx.getFilters()
print filters

Upload an image to the AviaryFX Service

The upload() method is used to upload image files to the AviaryFX Service to apply effects to them. This method returns a dict with a url to the file on the server. The returned image url should be used for subsequent interactions.

To upload an image:

uploadResponse = aviaryfx.upload(UPLOAD_DIR + "ostrich.jpg")
print uploadResponse

Render thumbnails

Use the renderOptions() method to render a thumbnail grid of the image with preset filter options for the selected filter. This returns a dict with a url to the thumbnail grid and render option parameters for each of the requested number of options for the filter.

To render a 3x3 thumbnail grid with 128px x 128px cells:

backgroundColor = "0xFFFFFFFF"
format = "jpg"
quality = "100"
scale = "1"
filepath = "path/to/file/returned/after/upload"
filterid = "28"
cols = "3"
rows = "3"
cellWidth = "128"
cellHeight = "128"
renderOptionsResponse = aviaryfx.renderOptions(backgroundColor, format, quality, scale, filepath, filterid, cols, rows, cellWidth, cellHeight)
print renderOptionsResponse

Render full image

Once an option is selected call the render() method along with the filter ID, image url and the parameters for the selected option. This returns a dict with the URL to rendered image.

backgroundColor = "0xFFFFFFFF"
format = "jpg"
quality = "100"
scale = "1"
width = "0"
height = "0"
filepath = "path/to/file/returned/after/upload"
filterid = "22"
renderParameters = [{"id":"Gamma","value":"2.6706531248452734"},{"id":"Smoothing","value":"4"},{"id":"Caption Index","value":"50"}]
renderResponse = aviaryfx.render(backgroundColor, format, quality, scale, filepath, filterid, width, height, renderParameters)
print renderResponse

Methods

Check out the official Aviary Effects API documentation for more details about the Aviary Effects API and class methods.

Feedback and questions

Found a bug or missing a feature? Don't hesitate to create a new issue here on GitHub, post to the Google Group or email us.

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.