Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active August 2, 2023 15:00
Show Gist options
  • Save aspose-com-gists/da84aef5e873f7e0e2f77889a3228dd5 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/da84aef5e873f7e0e2f77889a3228dd5 to your computer and use it in GitHub Desktop.

Aspose.Imaging Java API allows allows programmatically convert your svg images to various image formats with high quality in your Java application or Web service.

You can:

  • convert svg to raster image;
  • convert svg to vector image.

Interested ?

You may go further at : https://products.aspose.com/imaging/java/

import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of ApngOptions
ApngOptions exportOptions = new ApngOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to apng
image.save(outputFolder + File.separator + "svg-to-apng-output.apng", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of BmpOptions
BmpOptions exportOptions = new BmpOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to bmp
image.save(outputFolder + File.separator + "svg-to-bmp-output.bmp", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of DicomOptions
DicomOptions exportOptions = new DicomOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to dicom
image.save(outputFolder + File.separator + "svg-to-dicom-output.dicom", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
DxfOptions exportOptions = new DxfOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to dxf
image.save(outputFolder + File.separator + "svg-to-dxf-output.dxf", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of EmfOptions
EmfOptions exportOptions = new EmfOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to emf
image.save(outputFolder + File.separator + "svg-to-emf-output.emf", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
EmfOptions exportOptions = new EmfOptions();
exportOptions.setCompress(true);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to emz
image.save(outputFolder + File.separator + "svg-to-emz-output.emz", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of GifOptions
GifOptions exportOptions = new GifOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to gif
image.save(outputFolder + File.separator + "svg-to-gif-output.gif", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
Html5CanvasOptions exportOptions = new Html5CanvasOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to html
image.save(outputFolder + File.separator + "svg-to-html-output.html", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of IcoOptions
IcoOptions exportOptions = new IcoOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to ico
image.save(outputFolder + File.separator + "svg-to-ico-output.ico", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
import com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Codec;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
Jpeg2000Options exportOptions = new Jpeg2000Options();
exportOptions.setCodec(Jpeg2000Codec.J2K);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to j2k
image.save(outputFolder + File.separator + "svg-to-j2k-output.j2k", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
import com.aspose.imaging.fileformats.jpeg2000.Jpeg2000Codec;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
Jpeg2000Options exportOptions = new Jpeg2000Options();
exportOptions.setCodec(Jpeg2000Codec.Jp2);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to jp2
image.save(outputFolder + File.separator + "svg-to-jp2-output.jp2", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of JpegOptions
JpegOptions exportOptions = new JpegOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to jpeg
image.save(outputFolder + File.separator + "svg-to-jpeg-output.jpeg", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of Jpeg2000Options
Jpeg2000Options exportOptions = new Jpeg2000Options();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to jpeg2000
image.save(outputFolder + File.separator + "svg-to-jpeg2000-output.jpeg2000", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
JpegOptions exportOptions = JpegOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to jpg
image.save(outputFolder + File.separator + "svg-to-jpg-output.jpeg", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of PdfOptions
PdfOptions exportOptions = new PdfOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to pdf
image.save(outputFolder + File.separator + "svg-to-pdf-output.pdf", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of PngOptions
PngOptions exportOptions = new PngOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to png
image.save(outputFolder + File.separator + "svg-to-png-output.png", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of PsdOptions
PsdOptions exportOptions = new PsdOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to psd
image.save(outputFolder + File.separator + "svg-to-psd-output.psd", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of SvgOptions
SvgOptions exportOptions = new SvgOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to svg
image.save(outputFolder + File.separator + "svg-to-svg-output.svg", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
SvgOptions exportOptions = new SvgOptions();
exportOptions.setCompress(true);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to svgz
image.save(outputFolder + File.separator + "svg-to-svgz-output.svgz", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of TgaOptions
TgaOptions exportOptions = new TgaOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to tga
image.save(outputFolder + File.separator + "svg-to-tga-output.tga", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
import com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.Default);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to tif
image.save(outputFolder + File.separator + "svg-to-tif-output.tiff", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
import com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
TiffOptions exportOptions = new TiffOptions(TiffExpectedFormat.Default);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to tiff
image.save(outputFolder + File.separator + "svg-to-tiff-output.tiff", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
WebPOptions exportOptions = new WebPOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to webp
image.save(outputFolder + File.separator + "svg-to-webp-output.webp", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
// Create an instance of WmfOptions
WmfOptions exportOptions = new WmfOptions();
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to wmf
image.save(outputFolder + File.separator + "svg-to-wmf-output.wmf", exportOptions);
}
}
}
import java.io.File;
import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.*;
//You can get all image templates from https://github.com/aspose-imaging/Aspose.Imaging-for-Java/blob/master/Examples/Data/Templates.zip
//After download archive please unpack it and replace templatesFolder variable path with your path to unpacked archive folder
public class Main {
public static void main(String[] args) {
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (templatesFolder == null)
templatesFolder = "data";
if (outputFolder == null)
outputFolder = "out";
// Load the svg file in an instance of Image
try (Image image = Image.load(templatesFolder + File.separator + "template.svg")) {
WmfOptions exportOptions = new WmfOptions();
exportOptions.setCompress(true);
SvgRasterizationOptions vectorOptions = new SvgRasterizationOptions();
vectorOptions.setPageWidth(image.getWidth());
vectorOptions.setPageHeight(image.getHeight());
exportOptions.setVectorRasterizationOptions(vectorOptions);
// Save svg to wmz
image.save(outputFolder + File.separator + "svg-to-wmz-output.wmz", exportOptions);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment