Pixaven is a modern, GPU-powered image processing API.
We transform, enhance, adjust, crop, stylize, filter and watermark your images with blazing speed.
The official Java integration for the Pixaven API.
See the Pixaven API docs.
Pixaven API enables you to provide your images for processing in two ways - by uploading them directly to the API (Image Upload) or by providing a publicly available image URL (Image Fetch).
You may also choose your preferred response method on a per-request basis. By default, the Pixaven API will return a JSON response with rich metadata pertaining to input and output images. Alternatively, you can use binary responses. When enabled, the API will respond with a full binary representation of the resulting (output) image. This Java integration exposes two convenience methods for interacting with binary responses: toFile() and toBuffer().
Here is a quick example of uploading a local file for processing. It calls toJSON() at a final step and instructs the API to return a JSON response.
packagecom.pixaven.examples;
// Import dependenciesimportstaticcom.pixaven.OperationConfiguration.settings;
importcom.pixaven.Pixaven;
importcom.pixaven.Upload;
importcom.pixaven.Response;
publicclassExample {
publicstaticvoidmain(String[] args) {
// Pass your Pixaven API Key to the constructorPixavenpix = newPixaven("your-api-key");
// Upload an image for processing with `upload()` methodfinalUploadupload = pix.upload("path/to/input.jpg");
// Resize the image to 100 x 75upload.resize(
settings()
.set("width", 100)
.set("height", 75)
);
// Automatically enhance the imageupload.auto(
settings().set("enhance", true)
);
// Adjust sharpness parameterupload.adjust(
settings().set("unsharp", 10)
);
try {
// Finalize the chain with .toJSON()finalResponseresponse = upload.toJSON();
// You can access the full JSON metadata with `Response#getMetadata()`if (response.isSuccessful()) {
System.out.println(response.getMetadata().getOutput().get("url"));
} else {
System.out.println(response.getMessage());
}
} catch (IOExceptionio) {
// handle IOException
}
}
}If you already have your source visuals publicly available online, we recommend using Image Fetch by default. That way you only have to send a JSON payload containing image URL and processing steps. This method is also much faster than uploading a full binary representation of the image.
packagecom.pixaven.examples;
// Import dependenciesimportstaticcom.pixaven.OperationConfiguration.settings;
importcom.pixaven.Pixaven;
importcom.pixaven.Fetch;
importcom.pixaven.Response;
publicclassExample {
publicstaticvoidmain(String[] args) {
// Pass your Pixaven API Key to the constructorPixavenpix = newPixaven("your-api-key");
// Provide a publicly available image URL with `fetch()` methodfinalFetchfetch = pix.fetch("https://www.website.com/image.jpg");
// Apply Gaussian blurfetch.filter(
settings()
.set("blur", settings()
.set("mode", "gaussian")
.set("value", 10)
)
);
// Use PNG as output formatfetch.output(
settings().set("format", "png")
);
try {
// Finalize the chain with .toFile()finalResponseresponse = fetch.toFile("path/to/output.jpg");
// You can access the full JSON metadata with `Response#getMetadata()`if (response.isSuccessful()) {
System.out.println(response.getMetadata().getOutput().get("url"));
} else {
System.out.println(response.getMessage());
}
} catch (IOExceptionio) {
// handle IOException
}
}
}This software is distributed under the MIT License. See the LICENSE file for more information.
