Learn how to adjust image contrast, brightness and gamma in Java: https://blog.aspose.com/2021/11/27/adjust-image-contrast-brightness-gamma-in-java/
Last active
December 27, 2021 15:00
-
-
Save aspose-com-gists/99f3272cfbe5139edcb43f7d7bfacb3e to your computer and use it in GitHub Desktop.
Adjust Image Contrast, Brightness, and Gamma in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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