Convert Image to JPG in Java
Convert image files to JPG using Aspose.Slides for Java without Microsoft PowerPoint.
Convert Image to JPG in Java
Aspose.Slides for Java
is a presentation processing API that can add image files to slides and render them as JPG output.
You can load an image as an IPPImage, place it in a picture frame, render the slide as an IImage, and save it with ImageFormat.Jpeg.
Convert Image to JPG using Java
To convert an image to JPG, add the source image to a Presentation and render the slide.
Java code for converting Image into JPG
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("image.png"));
IPPImage presentationImage = presentation.getImages().addImage(imageData);
slide.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, 720, 540, presentationImage);
IImage slideImage = slide.getImage(1f, 1f);
try {
slideImage.save("image.jpg", ImageFormat.Jpeg);
} finally {
slideImage.dispose();
}
} finally {
presentation.dispose();
}
How to convert Image to JPG using Aspose.Slides for Java API
These are the steps to convert Image to JPG in Java.
Install Aspose.Slides for Java .
Add a library reference (import the library) to your Java project.
Load the source image as an
IPPImage.Render the slide as an
IImageand save it withImageFormat.Jpeg.
Free Online Converter
Convert presentations and slides online.
Convert Image To Other Supported Formats
You can also convert images and save them to other file formats.