Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active May 22, 2022 16:01
Show Gist options
  • Save aspose-com-kb/06c4b1932843cdce4bd32c00f56d52ae to your computer and use it in GitHub Desktop.
Save aspose-com-kb/06c4b1932843cdce4bd32c00f56d52ae to your computer and use it in GitHub Desktop.
Code to Resize SVG Image in Java. Refer to this article for more information: https://kb.aspose.com/imaging/java/how-to-resize-svg-image-in-java/
import com.aspose.imaging.Image;
import com.aspose.imaging.License;
import com.aspose.imaging.ResizeType;
public class ResizeSvgImageInJava {
public static void main(String[] args) // Main function to resize SVG image in Java
{
// Instantiate a license to avoid watermark in the output resized SVG file
License licForSvgResizing = new License();
licForSvgResizing.setLicense("Aspose.Imaging.lic");
// Load the source SVG image file that needs to be resized
Image img = Image.load("Circle.svg");
// Set the new size of the SVG image along with the resize type
img.resize(img.getWidth() * 2, img.getHeight() * 2, ResizeType.CenterToCenter);
// Save the resized SVG image on the disk
img.save("ResizedSvg.svg");
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment