Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 27, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/99f3272cfbe5139edcb43f7d7bfacb3e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/99f3272cfbe5139edcb43f7d7bfacb3e to your computer and use it in GitHub Desktop.
Adjust Image Contrast, Brightness, and Gamma in Java
// Load image
RasterImage image = (RasterImage) com.aspose.imaging.Image.load("image.png");
// Cache image for better performance
if (!image.isCached()) {
image.cacheData();
}
// Adjust the brightness
image.adjustBrightness(70);
// Save image
image.save("image-updated-brightness.png");
// Load image
RasterImage image = (RasterImage) com.aspose.imaging.Image.load("image.png");
// Cache image for better performance
if (!image.isCached()) {
image.cacheData();
}
// Adjust contrast
image.adjustContrast(30);
// Save image
image.save("image-updated-contrast.png");
// Load image
RasterImage image = (RasterImage) com.aspose.imaging.Image.load("image.png");
// Cache image for better performance
if (!image.isCached()) {
image.cacheData();
}
// Adjust gamma
image.adjustGamma(2.2f, 2.2f, 2.2f);
// Save image
image.save("image-updated-gamma.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment