How to Convert GIF to BMP with Java REST API

The following step by step tutorial shows you how to convert GIF to BMP with Java REST API. A GIF (Graphics Interchange Format) is a bitmap image format that was developed by CompuServe in 1987 and is now widely used on the internet for the display of images. GIFs are typically compressed and limited to a maximum of 256 colors, making them ideal for simple graphics and logos. GIFs are also widely used for small animations and low-resolution video clips.

On the contrary, BMP (Bitmap) is an image file format used to store bitmap digital images. It is a popular image format used mainly in the Windows operating system. BMP files are uncompressed raster images composed of a rectangular grid of pixels. The format supports up to 24 bits per pixel, allowing for a wide range of colors. If you want GIF to BMP Conversion in Java Low Code API then this can be performed with the help of code given below.

Prerequisite

Steps to Convert GIF to BMP in Java REST API

  1. Set Client ID and Client Secret for the API
  2. Create an instance of ImagingAPI class with client credentials
  3. Specify input and output files
  4. Read input GIF file and upload to cloud storage
  5. Create an object of ConvertImageRequest with input and output file formats
  6. Call convertImage method to Convert GIF to BMP using REST API
  7. Save the output BMP file on local disk

Code for GIF to BMP Conversion in Java Low Code API

String ClientID = Client.getID(); //replace Client.getID() with your own client ID here
String ClientSecret = Client.getSecret(); //replace Client.getSecret() with your own client secret here
String APIBaseUrl="https://api.aspose.cloud";
String Local_Path = "C:/Temp/";
ImagingApi imagingApiSdk = new ImagingApi(ClientSecret, ClientID, APIBaseUrl);
// Input & output file names
String inputFileName = "GIFtoBMP.gif";
String outputFileName = "GIFtoBMP.bmp";
try {
// Upload local image to Cloud Storage
File inputFile = new File(Local_Path + inputFileName);
FileInputStream inputFileStream = new FileInputStream(inputFile);
byte[] inputImageData = IOUtils.toByteArray(inputFileStream);
UploadFileRequest uploadFileRequest = new UploadFileRequest(inputFileName, inputImageData, null);
FilesUploadResult filesUploadResult = imagingApiSdk.uploadFile(uploadFileRequest);
String outputFormat = "bmp";
String remoteFolder = null; // Input file is saved at the root of the storage
String remoteStorage = null; // Cloud Storage name
ConvertImageRequest convertImageRequest = new ConvertImageRequest(inputFileName, outputFormat, remoteFolder, remoteStorage);
byte[] convertedImageData = imagingApiSdk.convertImage(convertImageRequest);
// Save exported image to local storage
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFileName);
fileOutputStream.write(convertedImageData);
fileOutputStream.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}

The code snippet given on this page helps you to convert GIF to BMP with Java REST API. You merely need to supply GIF file with the help of the Aspose.Imaging REST API SDK and download output BMP file to save it locally.

This GIF to BMP Conversion can be put to use with any no code or low code apps on any operating system.

You can also check a related topic at the following link: How to Convert JPEG2000 to PDF with Java REST API

 English