How to store Bitmaps as JPEGs

146 views
Skip to first unread message

ja...@printtapp.com

unread,
Jan 30, 2018, 8:25:13 AM1/30/18
to pdfium
Currently I generate a new PDF by rendering the old one to a bitmap and applying some transforms / other effects.

This causes the new image to be a decompressed image object when the original content was a decompressed JPEG.

Is there a way to get PDFium to re-encode it as a JPEG when needed ? Some documents balloon from 300kb to 10MB

Dan Sinclair

unread,
Jan 30, 2018, 9:16:49 AM1/30/18
to ja...@printtapp.com, pdfium
I don't know of any API to do this at the moment. Something will need to be added, thank you for filing a bug on the issue.

dan


--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+unsubscribe@googlegroups.com.
To post to this group, send email to pdf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/bb973734-dbff-4e79-83d5-ac6bf5255f36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ja...@printtapp.com

unread,
Jan 30, 2018, 10:08:46 AM1/30/18
to pdfium
So after some digging the only way currently is to read the buffer for the bitmap, use libjpeg directly to create a new compressed JPEG either in disk or memory.

Load that JPEG into PDFium using it's APIs (Which presumably means you will have the same image in memory 2 - 3 times), attach it to a page object like normal and then save it.

PDFium seems to keep track of the fact that image came from a JPEG and so the final PDF will have a JPEG in it.

Will do some more digging to see if this is compressed or not.


On Tuesday, January 30, 2018 at 2:16:49 PM UTC, Dan Sinclair wrote:
I don't know of any API to do this at the moment. Something will need to be added, thank you for filing a bug on the issue.

dan

On Tue, Jan 30, 2018 at 8:25 AM, <ja...@printtapp.com> wrote:
Currently I generate a new PDF by rendering the old one to a bitmap and applying some transforms / other effects.

This causes the new image to be a decompressed image object when the original content was a decompressed JPEG.

Is there a way to get PDFium to re-encode it as a JPEG when needed ? Some documents balloon from 300kb to 10MB

--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages