A library for the Aviary Effects API written in PHP.
To test run example/test.php in the browser. This should run all the methods and print the output.
The Aviary Effects API is exposed via the AviaryFX class.
To create an instance of the class with your API key and API secret:
require_once("AviaryFX.php");
$api_key = "demoapp";
$api_secret = "demoappsecret";
$aviaryfx = new AviaryFX($api_key, $api_secret);
The getFilters() method returns an array of filters that contain the label, uid and description for each filter. These can be used to render images.
To get the array of filters:
$getFiltersResponse = $aviaryfx->getFilters();
print_r($getFiltersResponse);
The upload() method is used to upload image files to the AviaryFX Service to apply effects to them. This method returns an array with a url to the file on the server. The returned image url should be used for subsequent interactions.
To upload an image:
$file = 'uploads/ostrich.jpg';
$uploadResponse = $aviaryfx->upload($file);
print_r($uploadResponse);
Use the renderOptions() method to render a thumbnail grid of the image with preset filter options for the selected filter. This returns an array with a url to the thumbnail grid and render option parameters for each of the requested number of options for that filter.
To render a 3x3 thumbnail grid with 128px x 128px cells:
$backgroundcolor = "0xFFFFFFFF";
$format = "jpg";
$quality = "100";
$scale = "1";
$filepath = $uploadResponse["url"];
$filterid = "22";
$cols = "3";
$rows = "3";
$cellwidth = "128";
$cellheight = "128";
$renderOptionsResponse = $aviaryfx->renderOptions($backgroundcolor, $format, $quality, $scale, $filepath, $filterid, $cols, $rows, $cellwidth, $cellheight);
print_r($renderOptionsResponse);
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";
$renderparameters = array ( "parameter" => array ( array("id" => "Gamma", "value" => 2.3908640030750226 ),
array("id" => "Smoothing", "value" => 4 ),
array("id" => "Caption Index", "value" => 50 )
)
);
$renderResponse = $aviaryfx->render($backgroundcolor, $format, $quality, $scale, $filepath, $filterid, $width, $height, $renderparameters);
print_r($renderResponse);
Check out the official Aviary Effects API documentation for more details about the Aviary Effects API and class methods.
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.