We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PNG Filter on PDF

Dear Support,

I have a pdf with png image in it that has PNG Filter of type 3 and type 4 (Average and Paeth). I am looking to convert this png image stream in the pdf, from Filter type 3 and type 4 to may be, Filter type 1 or 2. I understand that by doing this conversion, I may increase the size of pdf stream and the pdf in general.

Do you provide an efficient API for such a conversion?

Link to refer for filter type 0-4: http://www.w3.org/TR/REC-png.pdf (page # 26-29)

Thank you!

Hi Thor,

Thanks for your inquiry. I am afraid Aspose.Pdf does not manipulating Images(PNG in your case). However, we have an Imaging API (Aspose.Imaging). It can create or manipulate images very efficiently. My Aspose.Imaging colleague will confirm you about the support of converting filters in PNG image. And if it is is supported then you can initially extract images from PDF document using Aspose.Pdf, manipulate images and replace old image with new one.

Best Regards,

Hi Thor,

Thank you for your inquiry.

Please, note that Aspose.Imaging API exposes PngOptions class. This class has a property named FilterType, using FilterType property you can specify any filter method among the five filter methods including 0 for none. For more information on filet methods, access the link PngFilterType Enumberation.

Following is the sample code for your reference.
using (Aspose.Imaging.FileFormats.Png.PngImage png =
(Aspose.Imaging.FileFormats.Png.PngImage)Aspose.Imaging.Image.Load(sourceFilePath))
{
//Create an instance of PngOptions
Aspose.Imaging.ImageOptions.PngOptions options = new Aspose.Imaging.ImageOptions.PngOptions();

//Set the PNG filter method
options.FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.Paeth;
//Save changes to the disc
png.Save(destFilePath, options);
}

Hope the above information helps. Please feel free to write us back in case you have further concerns or questions for us.