Ameto API reference

Operations on assets

Retrieve available assets

Ameto ameto = new Ameto();
Set<Asset> availableAssets = ameto.getAssets();

Ameto allows the user to retrieve a list of available asset objects. The list only contains "original" assets, that means it does not include the results of pipelines. Assets that are the result of applying a pipeline to an asset are referred to as variants. A list of variants can be retrieved per asset.

Processed assets are available as a list of variants of the original asset.

Set<ProcessedAsset> thumbnailsInDifferentSizes = originalImage.getVariants();

Upload an asset

Ameto ameto = new Ameto();
Path assetFile = Paths.get("my_asset.jpg");
Asset asset = ameto.add(assetFile);

Assets can be uploaded to Ameto from different sources. The asset must be passed to Ameto as binary content. Once an asset is uploaded, it will never be modified. Since all Operations on assets are non-destructive, you can retrieve the original asset at any time. Assets will be kept indefinitely, unless the user explicitly deletes them.

Delete an asset

Ameto ameto = new Ameto();
ameto.remove(asset);

Assets can be deleted from Ameto. Processed assets can be deleted in the same way. Removing an asset is irreversible, so make sure you have a local backup.

Operations on pipelines

Create a processing pipeline

Ameto ameto = new Ameto();
Pipeline shrinkPipeline = ameto.addPipeline("convertToJpeg")
                               .format(Pipeline.Format.Jpeg)
                               .build();

Ameto allows the user to create custom processing pipelines. A pipeline requires a unique identifier and a list of operators that should be applied to assets. If two pipelines with the same name are added to Ameto, the latest pipeline replaces the pipelines that were created earlier.

Every pipeline requires the output format to be specified. Currently, only JPEG output is supported. Note that Ameto uses an optimized JPEG encoder that results in smaller file sizes than conventional JPEG encoders.

Retrieve available pipelines

Ameto ameto = new Ameto();
Set<Pipeline> availablePipelines = ameto.getPipelines();

It is possible to retrieve a list of available pipelines from Ameto. Note that the list of available pipelines may not contain pipelines that were added very recently.

Available pipeline operations

Resize

Changes the width and height of an image to the specified dimensions while preserving aspect ratio.

ameto.addPipeline("800x600")
     .resize(800, 600, Resize.Mode.FIT)
     .format(Pipeline.Format.Jpeg)
     .build();

The resize operation takes an input image and adjusts the image size to the specified dimensions. It supports JPEG as input format and creates PNG files.

The operator supports three different modes of operations: exact resizing, fit-to-size, and fill area. In exact mode the operation yields an output image with the exact specified dimensions ignoring the aspect ratio of the input image. The fill mode preserves the aspect ratio of the original image and resizes it to fully cover an area of the specified dimensions. The fit mode also preserves the original image's aspect ratio and returns an image which does not exceed the specified dimensions. This is the default behaviour if no resize mode is specified.

Supported input MIME types : image/jpeg

Supported output MIME types : image/png

Auto-Orient

Normalizes the image orientation based on its Exif metadata.

ameto.addPipeline("auto-orient")
     .autoOrient()
     .format(Pipeline.Format.Jpeg)
     .build();

The auto-orient operator reads an image's Exif metadata and rotates the image accordingly. To learn more about the Exif orientation field, refer to our Exif orientation primer.

Supported input MIME types : image/jpeg

Supported output MIME types : image/jpeg