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.Color; | |
import com.aspose.imaging.Image; | |
import com.aspose.imaging.RasterImage; | |
import com.aspose.imaging.examples.Utils; | |
public class Deskew | |
{ | |
public static void main(String... args) | |
{ | |
// The path to the documents directory. |
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
// Setting a memory limit of 10 megabytes for target loaded image | |
LoadOptions loadOptions = new LoadOptions(); | |
loadOptions.setBufferSizeHint(10); | |
try (Image image = Image.load("example.cmx", loadOptions)) | |
{ | |
CmxRasterizationOptions vectorOptions = new CmxRasterizationOptions(); | |
vectorOptions.setTextRenderingHint(TextRenderingHint.SingleBitPerPixel); | |
vectorOptions.setSmoothingMode(SmoothingMode.AntiAlias); | |
vectorOptions.setPositioning(PositioningTypes.DefinedByDocument); | |
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
// The path to the documents directory. | |
String dataDir = "images/"; | |
//Create an instance of BmpCreateOptions and set its various properties | |
try(com.aspose.imaging.imageoptions.BmpOptions createOptions = new com.aspose.imaging.imageoptions.BmpOptions()) | |
{ | |
createOptions.setBitsPerPixel(24); | |
//Create an instance of FileCreateSource and assign it to Source property | |
createOptions.setSource(new com.aspose.imaging.sources.FileCreateSource(dataDir + "sample.bmp",false)); |
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
final int ImageSize = 2000; | |
try (ImageOptionsBase createOptions = new PngOptions()) | |
{ | |
createOptions.setSource(new FileCreateSource("temporary.png")); | |
createOptions.setBufferSizeHint(30); // Memory limit is 30 Mb | |
try (Image image = Image.create(createOptions, ImageSize, ImageSize)) | |
{ | |
Graphics graphics = new Graphics(image); | |
// You can use any graphic operations here, all of them will be performed within the established memory limit | |
// For example: |
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
LoadOptions options = new LoadOptions(); | |
options.setBufferSizeHint(50); | |
// Setting a memory limit of 50 megabytes for target loaded image | |
try (Image image = Image.load("inputFile.jpg", options)) | |
{ | |
JpegOptions jpegOptions = new JpegOptions(); | |
jpegOptions.setCompressionType(JpegCompressionMode.Baseline); | |
jpegOptions.setQuality(100); | |
image.save("outputFile_Baseline.jpg", jpegOptions); | |
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
// Example of use of separate operation progress event handlers for load/export operations | |
String fileName = "some file to load"; | |
LoadOptions loadOptions = new LoadOptions(); | |
loadOptions.setProgressEventHandler(new ProgressEventHandler() | |
{ | |
@Override | |
public void invoke(ProgressEventHandlerInfo info) | |
{ | |
System.out.format("Load event %s : %d/%d\n", EventType.toString(EventType.class, info.getEventType()) | |
, info.getValue(), info.getMaxValue()); |
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
String inputFileName = "Logotype.svg"; | |
try (Image image = Image.load(inputFileName)) | |
{ | |
image.resize(image.getWidth() * 10,image.getHeight() * 15); | |
image.save("Logotype_10_15.png", new PngOptions() | |
{{ | |
setVectorRasterizationOptions(new SvgRasterizationOptions()); | |
}}); | |
} |
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
// Setting a memory limit of 10 megabytes for target loaded image | |
// JP2 codec | |
try (Image image = Image.load("inputFile.jp2", new LoadOptions() {{ setBufferSizeHint(10); }})) | |
{ | |
image.save("outputFile.jp2"); | |
} | |
// J2K codec | |
try (Image image = Image.load("inputFile.j2k", new LoadOptions() {{ setBufferSizeHint(10); }})) | |
{ |
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
// Setting a memory limit of 50 megabytes for target loaded image | |
try (DjvuImage image = (DjvuImage)Image.load("test.djvu", new LoadOptions() {{ setBufferSizeHint(50); }})) | |
{ | |
int pageNum = 0; | |
for (DjvuPage page : image.getPages()) | |
{ | |
page.save("page" + pageNum + ".png", new PngOptions()); | |
pageNum++; | |
} | |
} |
OlderNewer