Created
December 21, 2020 21:58
-
-
Save farhan-raza/2deae32cef47fc73a97d2f843dac8bea to your computer and use it in GitHub Desktop.
Convert AI files to PSD, PDF, JPEG or PNG Image Format Programmatically in Java
This file contains hidden or 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
| String dataDir = Utils.getDataDir(AIToJPG.class) + "AI/"; | |
| String sourceFileName = dataDir + "34992OStroke.ai"; | |
| String outFileName = dataDir + "34992OStroke.jpg"; | |
| // Load input AI file | |
| AiImage image = (AiImage)Image.load(sourceFileName); | |
| // Initialize JpegOptions class instance | |
| JpegOptions options = new JpegOptions(); | |
| options.setQuality(85); | |
| // Save output JPEG image | |
| image.save(outFileName, options); |
This file contains hidden or 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
| String sourceFileName = dataDir + "34992OStroke.ai"; | |
| String outFileName = dataDir + "34992OStroke.pdf"; | |
| // Load input AI image file | |
| AiImage image = (AiImage)Image.load(sourceFileName); | |
| // Initilize PdfOptions object to specify different options | |
| PdfOptions options = new PdfOptions(); | |
| // Save output PDF file | |
| image.save(outFileName, options); |
This file contains hidden or 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
| String dataDir = Utils.getDataDir(AIToPNG.class) + "AI/"; | |
| String sourceFileName = dataDir + "34992OStroke.ai"; | |
| String outFileName = dataDir + "34992OStroke.png"; | |
| // Load input AI file | |
| AiImage image = (AiImage)Image.load(sourceFileName); | |
| // Initilaize PngOptions instance | |
| PngOptions options = new PngOptions(); | |
| options.setColorType(PngColorType.TruecolorWithAlpha); | |
| // Save output PNG image | |
| image.save(outFileName, options); |
This file contains hidden or 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
| String dataDir = Utils.getDataDir(AIToPSD.class) + "AI/"; | |
| String sourceFileName = dataDir + "34992OStroke.ai"; | |
| String outFileName = dataDir + "34992OStroke.psd"; | |
| // Load input image | |
| AiImage image = (AiImage)Image.load(sourceFileName); | |
| // Initialize PsdOptions class object | |
| PsdOptions options = new PsdOptions(); | |
| // Save output PSD file | |
| image.save(outFileName, options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment