Low quality output when saving JPEG image using Aspose.Slides for .NET

Hello,

Just opening and saving any JPG image with Aspose is producing an output file which is half the file size of Original. More importantly, output file is of quite low quality. Then, we used another approach of saving the file using JpgCreateOptions. However, we noticed that output file was again of low quality.

Code snippet is share below for both the approaches. Also, attaching a zip file with input and output files for your reference.

We would like to produce an output file of similar size and quality using Aspose. Could you please look into this and share your findings?

public static void RunApproach1()
{
	// The path to the documents directory.
	string dataDir = RunExamples.GetDataDir_JPEG();
	// Load an image using the factory method Load exposed by Image class
	using (Image image = Image.Load(dataDir + "aspose-logo.jpg"))
	{
		image.Save(dataDir + "aspose-logo_out.jpg");
	}
}
// Output is:
// aspose-logo.jpg: Original size is 14.8 kb. After saving, 7.95 kb.
// Image2.jpg: Original size is 256 kb. After saving, 130 kb.

public static void RunApproach2()
{
	// The path to the documents directory.
	string dataDir = RunExamples.GetDataDir_JPEG();
	string sourceFile = dataDir + @"aspose-logo.jpg";
	string destFileName = dataDir + @"aspose-logo_Output.jpg";
	using (var newImage = (RasterImage)Image.Load(sourceFile))
	{
		//Create an instance of JpegOptions for resultant Jpeg file 
		var JpgCreateOptions = new ImageOptions.JpegOptions();
		//Set the Quality 
		JpgCreateOptions.Quality = 100;
		JpgCreateOptions.CompressionType = JpegCompressionMode.Progressive;
		//Set the file source of resultant Jpeg. Last parameter denotes isTemporal 
		JpgCreateOptions.Source = new Sources.FileCreateSource(destFileName, false);
		//Create a new JpegImage using JpegOptions and size in Width and Height of source image 
		using (var JpgImage = (JpegImage)Image.Create(JpgCreateOptions, newImage.Width, newImage.Height))
		{
			//Set Resolution 
			//JpgImage.HorizontalResolution = 300; 
			//JpgImage.VerticalResolution = 300; 
			if (JpgImage.ExifData == null)
			{
				JpgImage.ExifData = new JpegExifData();
			}
			JpgImage.ExifData.ResolutionUnit = Exif.Enums.ExifUnit.Inch;
			JpgImage.ExifData.XResolution = new FileFormats.Tiff.TiffRational((uint)newImage.Width);
			JpgImage.ExifData.YResolution = new FileFormats.Tiff.TiffRational((uint)newImage.Height);
			//Load all Pixels (Bitmap information) of source image and save them on Jpeg 
			JpgImage.SavePixels(JpgImage.Bounds, newImage.LoadPixels(newImage.Bounds));
			//JpgImage.Resize(width, height, ResizeType.LanczosResample);
			//Save the Jpeg 
			JpgImage.Save();
		}
	}
}
// Output is:
// aspose-logo.jpg: Original size is 14.8 kb. After saving, 11.5 kb.
// Image2.jpg: Original size is 256 kb. After saving, 873 kb.

InputAndOutputFiles.zip (1.3 MB)

@dcdeveloper,

I have worked with the image shared by you and have been able to observe the issue. An issue with ID IMAGINGNET-2993 has been created in our issue tracking system to investigate the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

Hello,

Thank you for your reply and raising an issue for this. I have few queries related to this issue:

  • What is causing this difference in file size of input and output image files?
  • Does this impact in quality of output image file?
  • Are there any alternative ways by which this can be avoided?
  • Do you have any updates on this with respect to timeline - when can this be fixed?

Thanks again and looking forward to your inputs.

@dcdeveloper,

I have observed your comments. I regret to inform that investigation in under process and we are unable to share any information with out detail investigation. I request for your patience and we will share good news with you soon.

The issues you have found earlier (filed as IMAGINGNET-2993) have been fixed in this update.