More often, GIF images are used to depict the animations. An animated GIF is a collection of frames combined together in a particular order. However, in certain cases, you have to convert GIF images to other raster image formats. For such cases, this article demonstrates how to convert a GIF image to PNG, JPEG, BMP, and TIFF formats using Java.
- Java GIF Converter API
- Convert GIF to PNG in Java
- Convert GIF to JPEG in Java
- GIF to BMP Conversion in Java
- GIF to TIFF Conversion in Java
- Get a Free API License
Info: Aspose recently developed a FREE Text to GIF Converter.
Java GIF Converter API
In order to convert GIF images, we’ll use Aspose.Imaging for Java. It is a feature-rich image processing API that provides a high quality back and forth conversion of popular image formats. You can either download the API or install it using the following Maven configurations.
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-imaging-java</artifactId>
<version>20.10</version>
<classifier>jdk16</classifier>
</dependency>
Convert GIF to PNG in Java
The following are the steps to convert a GIF image to PNG using Java.
- First, create an instance of the Image class and load the GIF image using Image.load(String) method.
- Create an instance of PngOptions class.
- Instantiate MultiPageOptions class to specify frame(s) to be converted.
- Use PngOptions.setMultiPageOptions(MultiPageOptions) method to set range of pages.
- Finally, use Image.save(String, PngOptions) method to convert GIF to PNG.
The following code sample shows how to convert a GIF image to PNG using Java.
Convert GIF to JPEG in Java
The following are the steps to convert GIF images to JPEG using Java.
- First, create an instance of the Image class and load the GIF image using Image.load(String) method.
- Create an instance of JpegOptions class.
- Instantiate MultiPageOptions class to specify frame(s) to be converted.
- Use JpegOptions.setMultiPageOptions(MultiPageOptions) method to set range of pages.
- Finally, use Image.save(String, JpegOptions) method to convert GIF to JPEG.
The following code sample shows how to convert GIF images to JPEG in Java.
Convert GIF to BMP using Java
The following are the steps to convert GIF images to BMP using Java.
- First, create an instance of the Image class and load the GIF image using Image.load(String) method.
- Create an instance of BmpOptions class.
- Instantiate MultiPageOptions class to specify frame(s) to be converted.
- Use BmpOptions.setMultiPageOptions(MultiPageOptions) method to set range of pages.
- Finally, use Image.save(String, BmpOptions) method to convert GIF to BMP.
The following code sample shows how to convert GIF images to BMP in Java.
Convert GIF to TIFF using Java
The following are the steps to convert GIF images to TIFF using Java.
- First. create an instance of the Image class and load the GIF image using Image.load(String) method.
- Create an instance of TiffOptions class.
- Instantiate MultiPageOptions class to specify frame(s) to be converted.
- Use TiffOptions.setMultiPageOptions(MultiPageOptions) method to set range of pages.
- Finally, use Image.save(String, TiffOptions) method to convert GIF to TIFF.
The following code sample shows how to convert GIF images to TIFF in Java.
Get a Free API License
You can try Aspose.Imaging for Java without evaluation limitations using a temporary license.
Conclusion
In this article, you have learned how to convert GIF images to JPEG, PNG, BMP, and TIFF images using Java. You can explore other features of the API using documentation. Furthermore, in case of any confusion, you can contact us via our forum.