gheeres / PDFSharp.Extensions

Extensions methods for PDFSharp to simplify common operations, including image extraction.
MIT License
34 stars 27 forks source link

Non-indexed 1bbp images #3

Closed trevorprinn closed 9 years ago

trevorprinn commented 9 years ago

I'm extracting all the images from a PDF (actually a jazz real book) where most of the pages are 1bbp. GetImages failed in PdfDictionaryExtensions.GetPixelFormat with "The specified pixel depth '1' is not supported". It seemed a bit odd that it would really need to be indexed so I tried taking out if (isIndexed) { return (PixelFormat.Format1bppIndexed);} and replacing it with just return (PixelFormat.Format1bppIndexed); That seems to work fine, at least on the pdf I've tested it on so far.

gheeres commented 9 years ago

Technically a 1bpp file is indexed. It's either 0 or 1. In fact, a 1bpp file isn't even necessarily black and white.

I would suspect that the index detection has an error then. Do you have an example of the dictionary header for the images. Or optionally send me the file (or a page from the file in question) so that I can inspect it.

trevorprinn commented 9 years ago

I've uploaded the file to http://www.mediafire.com/view/bee6b00j31gs6vx/THE_NEW_REAL_BOOK_VOL.I.pdf

gheeres commented 9 years ago

Thanks. I got the file so you can remove the link if there might be copyright problems, etc.

I'll try to look at it tomorrow if time permits, otherwise sometime next week (or this weekend if I get bored...).

gheeres commented 9 years ago

Looking over things, the fix you made was appropriate. Thanks! Updated NuGet packages.