How to Convert SVG to TIFF with Java REST API

This step by step tutorial elaborates how to convert SVG to TIFF with Java REST API. SVG (Scalable Vector Graphics) is a vector image format used to display a variety of graphics on the web and other digital platforms. It is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. SVG files can be created and edited with any text editor, and can be compressed and optimized for web or print.

On the contrary, TIFF (Tagged Image File Format) is a file format for storing images, popular among graphic artists, the publishing industry, and both amateur and professional photographers in general. It is a flexible format that can store pixel information from a range of sources, including scanned documents, digital photographs, and computer-generated art. The format supports lossless compression, allowing for high-quality images with smaller file sizes. If you want SVG to TIFF Conversion in Java Low Code API then the same can be done with the help of this sample code.

Prerequisite

Steps to Convert SVG to TIFF in Java REST API

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

Code for SVG to TIFF 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 = "SVGtoTIFF.svg";
String outputFileName = "SVGtoTIFF.tiff";
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 = "tiff";
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 above sample code empowers you to convert SVG to TIFF with Java REST API. You only have to provide SVG file with the help of the Aspose.Imaging REST API SDK and download output TIFF file to save it locally.

This SVG to TIFF Conversion could be used with any no code or low code apps on any platform.

You may also check out another similar feature at the following page: How to Convert JPG to BMP with Java REST API

 English