Convert JPG to Image in Java
Convert JPG files to image output using Aspose.Slides for Java without Microsoft PowerPoint.
Convert JPG to Image in Java
Aspose.Slides for Java
is a presentation processing API that can place a JPG file on a slide and render the slide as image output.
You can load a JPG file as an IPPImage, add it to a picture frame, render the slide as an IImage, and save the result with ImageFormat.Png.
Convert JPG to Image using Java
To convert JPG to image output, add the source file to a Presentation and render the slide.
Java code for converting JPG into Image
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
byte[] imageData = Files.readAllBytes(Paths.get("image.jpg"));
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.png", ImageFormat.Png);
} finally {
slideImage.dispose();
}
} finally {
presentation.dispose();
}
How to convert JPG to Image using Aspose.Slides for Java API
These are the steps to convert JPG to Image in Java.
Install Aspose.Slides for Java .
Add a library reference (import the library) to your Java project.
Load the source
JPGfile as anIPPImage.Render the slide as an
IImageand save it as an image file.
Free Online Converter
Convert presentations and slides online.
Convert JPG To Other Supported Formats
You can also convert JPG files and save them to other file formats.