Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 23, 2021 14:15
Show Gist options
  • Save aspose-com-gists/f9675e00226911e7351c3e80fc4c2baf to your computer and use it in GitHub Desktop.
Save aspose-com-gists/f9675e00226911e7351c3e80fc4c2baf to your computer and use it in GitHub Desktop.
Rotate and Flip Images in Java
// Load image
RasterImage image = (RasterImage) Image.load("image.bmp");
// Flip the image
image.rotateFlip(RotateFlipType.RotateNoneFlipX);
// Save image
image.save("rotated-image.bmp");
// 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");
// 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");
// 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