Support for multi-threaded environment and DNG format with Aspose.Imaging for Java 17.01

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Aspose.Imaging for Java logo We are pleased to announce the release of Aspose.Imaging for Java 17.01. The major development in this release is support for exporting images in multi threaded environment. Support for DNG format has also been incorporated in this release.

Export Images in Multi Threaded Environment

Aspose.Imaging for Java now supports exporting images in multi threaded environment. Aspose.Imaging for Java ensure the optimized performance of operations during execution of code in multi-threaded environment. All imaging option classes (e.g. BmpOptions, TiffOptions, JpegOptions, etc.) in the Aspose.Imaging for Java now implement IDisposable interface. Therefore it is a must that developer properly dispose off the imaging options class object in case getSyncRoot property is set. Following code snippet demonstrates the said functionality.



// Create temporary image.
        java.io.File tmp = java.io.File.createTempFile("image", "tes");
        
        // Delete the file. This statement should execute to make it sure that resource is properly disposed off.
        tmp.deleteOnExit();
        
        // Path & name of existing image.
        String imageDataPath = tmp.getAbsolutePath();

        // Create the stream of the existing image file.
        java.io.InputStream fileStream = new java.io.FileInputStream(tmp);
        try
        {
            // Create an instance of BMP image option class.
            com.aspose.imaging.imageoptions.BmpOptions bmpOptions = new com.aspose.imaging.imageoptions.BmpOptions();
            try
            {
		bmpOptions.setBitsPerPixel(32);
		
                // Set the source property of the imaging option class object.
                bmpOptions.setSource(new com.aspose.imaging.sources.StreamSource(fileStream));

                // Do processing. Following is the sample processing on the image. Un-comment to use it.
		// com.aspose.imaging.RasterImage image = (com.aspose.imaging.RasterImage)com.aspose.imaging.Image.create(bmpOptions, 10, 10);
		// try
		// {
		//	com.aspose.imaging.Color[] pixels = new com.aspose.imaging.Color[4];
		//	for (int i = 0; i < 4; ++i)
		//	{
		//		pixels[i] = com.aspose.imaging.Color.fromArgb(40, 30, 20, 10);
		//	}
		//	image.savePixels(new com.aspose.imaging.Rectangle(0, 0, 2, 2), pixels);
		//	image.save(imageDataPath);
		//}
		//finally
		//{
                    // This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
                //    image.dispose();
		//}
            }
            finally
            {
                // This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
                bmpOptions.dispose();
            }
        }
        finally
        {
            // This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
            fileStream.close();
            fileStream = null;
        }

Aspose.Imaging now supports getSyncRoot property while working in multi-threaded environment. Developer can use this property to synchronize access to the source stream. Following code snippet demonstrates how the getSyncRoot property can be used.


// create new synchronized two-way stream
        com.aspose.imaging.StreamContainer streamContainer = new com.aspose.imaging.StreamContainer(new java.io.ByteArrayInputStream(new byte[0]));
        try
        {
            // check if the access to the stream source is synchronized.
            synchronized (streamContainer.getSyncRoot())
            {
                    // do work
                    // now access to streamContainer is synchronized
            }
        }
        finally
        {
                streamContainer.dispose();
        }

Support for DNG Image

Aspose.Imaging for Java now supports the DNG (Digital Negative) image format (.dng). It is a publicly available archival format for the raw files generated by digital cameras. DNG helps ensure that photographers will be able to access their files in the future. Aspose.Imaging for Java provides the DngImage class to load DNG files and same can be used to convert the DNG to raster formats. Below provided sample code demonstrate how to convert a DNG file to JPEG format.



//Declare variables to store file paths for input and output images.
String sourceFiles = "Path_to_source_folder\\Source\\HDR - 3c.dng";
String destPath = "Path_to_results_folder\\Results\\result.jpg";

// Create an instance of Image class and load an exiting DNG file.
// Convert the image to DngImage object.
com.aspose.imaging.fileformats.dng.DngImage objimage = (com.aspose.imaging.fileformats.dng.DngImage)
                                                                com.aspose.imaging.Image.load(sourceFiles);
// Create an instance of JpegOptions class.
// convert and save to disk in Jpeg file format.
objimage.save(destPath, new com.aspose.imaging.imageoptions.JpegOptions());

Enhancements

Following enhancements have been introduced in this release.

  • Process of updating PSD text layer has been improved.

  • Processing of updating PSD text layer with non-English characters has been improved.

  • Processing of converting PSD layer to PNG format has been improved.

  • Processing of Aspose.Imaging API in multi-threaded environment has been improved.

Please refer to the release notes of Aspose.Imaging for Java 17.01 for a full view of improvements along with sample code snippets for newly added features. If you are planning to upgrade the API to the latest revision, we strongly suggest you to check the Public API Changes section to know what has been changed in the public API since your current version.

Aspose.Imaging for Java Resources

The resources, you may need to accomplish your tasks:

As always we appreciate your feedback so if you ever have anything to tell us about this release or anything else, please head to the Aspose.Imaging forum for a chat.


To keep up with our news, you can follow us on Twitter or follow our Facebook page.

Leave a Reply