Last active
May 22, 2022 16:01
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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