Learn how to rotate and flip images in Java: https://blog.aspose.com/2021/11/21/rotate-and-flip-images-in-java/
Last active
December 23, 2021 14:15
-
-
Save aspose-com-gists/f9675e00226911e7351c3e80fc4c2baf to your computer and use it in GitHub Desktop.
Rotate and Flip Images 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) Image.load("image.bmp"); | |
// Flip the image | |
image.rotateFlip(RotateFlipType.RotateNoneFlipX); | |
// Save image | |
image.save("rotated-image.bmp"); |
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) Image.load("image.bmp"); | |
// Rotate and flip the image | |
image.rotateFlip(RotateFlipType.Rotate180FlipX); | |
// Save image | |
image.save("rotated-image.bmp"); |
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) Image.load("image.bmp"); | |
// Cache image for better performance | |
if (!image.isCached()) { | |
image.cacheData(); | |
} | |
// Rotate at 20 degree while keeping the image size | |
image.rotate(20f); | |
// Save image | |
image.save("rotated-image.bmp"); |
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) Image.load("image.bmp"); | |
// Rotate the image | |
image.rotateFlip(RotateFlipType.Rotate270FlipNone); | |
// Save image | |
image.save("rotated-image.bmp"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment