I seem to be able to image PowerPoint pages to JPG using the Aspose.Drawing cross-platform replacement for System.Drawing. The sample code suggests pulling a Bitmap using slide.GetThumbnail and then using the Bitmap Save() method to output the page in the desired image format.
Sample:
slideImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
I would like to have some control over the Jpeg quality, such as the control Quality/JpegQuality save options provided by some of the other Aspose libraries (Word/Cells).
This would traditionally be done with something like this:
slideImage.Save(imageStream, jpegCodec, encoderParameters);
But that doesn’t work. There don’t appear to be any encoder options in the Aspose.Drawing.
Is there any way to set Jpeg Quality when performing a Bitmap Save() to a Jpeg format?
@hanastopoulos,
Thank you for contacting support. I am working on the issue you described and will get back to you as soon as possible.
Dear Audrey,
I don’t wish to publish this publicly, but I am going to try something like this:
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo jpegCodecInfo = codecs
.Where(item => item.Clsid == ImageFormat.Jpeg.Guid)
.Select(item => item)
.First();
var encoderParameters = new System.Drawing.Imaging.EncoderParameters(1);
encoderParameters.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, saveOptions.JpegQuality);
slideImage.Save(imageStream, jpegCodecInfo, encoderParameters);
I would prefer an easier approach and I don’t know if this is cross-platform, but this might be a workable approach.
Sincerely,
Harry Anastopoulos
Senior Software Engineer
Reveal Data Corporation
@hanastopoulos,
Thank you for showing the workaround.
Could you please point out with examples what you mean when mentioning the Aspose.Words and Aspose.Cells libraries?