PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Apr 25, 2024 7:27 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Extracting non-RGB JPEGs
PostPosted: Wed May 12, 2010 6:25 pm 
Offline

Joined: Thu Feb 25, 2010 2:44 pm
Posts: 14
I've been playing around with the ExportImages sample project. When I extracted images from a PDF file that used color space /DeviceCMYK for its JPEGs (and yes, I checked, and these images are using /DTCDecode), the colors were all screwed up. What do I need to do to get the colors right? Clearly simply writing the dictionary stream directly to disk wasn't the answer. (I even opened these images in PhotoShop and the colors were still screwy.)


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2010 8:00 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
JeffJohnson wrote:
What do I need to do to get the colors right?

All the information that Adobe Reader gets about the image is in the JPEG file and in the filter parameters of the PDF file.
Does the JPEG file contain a comment that names the creating application?

Does the image look inverted (negated)? This can be done by using filter parameters.
What do you mean with "screwy"?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2010 1:49 pm 
Offline

Joined: Thu Feb 25, 2010 2:44 pm
Posts: 14
Here's the entire dictionary describing one of the images:

<</Subtype/Image
/Length 536739
/Filter/DCTDecode
/BitsPerComponent 8
/ColorSpace/DeviceCMYK
/Width 782
/Height 650
/Type/XObject>>

Yes, the colors look inverted, but if I open the image in an editor and invert the colors, the result looks extremely overexposed, like there's not enough black.


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2010 3:01 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
We only have few CMYK JPEGs we used to test PDFsharp.
Those files look correct in Photoshop, but appeared inverted in PDF.
Therefore we added
Code:
Elements["/Decode"] = new PdfLiteral("[1 0 1 0 1 0 1 0]");

to make them look correct in PDF.

It seems your PDFs were created without this Decode trick - they changed the JPEG files to make them look correct.
I don't know how to help you.

You can try inverting CMY while keeping K.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2010 5:44 pm 
Offline

Joined: Thu Feb 25, 2010 2:44 pm
Posts: 14
It appears that this is a very complex PDF. Its purpose is to test color digital presses, so I guess the color encoding is very fine-tuned. As I look at other objects inside the PDF I see some functions which have /Decode entries similar to what you wrote. Of course, it's kind of hard to work backwards from objects to see exactly how they're being used, so I can't say for sure that the images are using these functions.

If it means anything to you, these are the functions:

46 0 obj
<</Length 147/FunctionType 0/Filter/FlateDecode/Encode[0 63]/BitsPerSample 8/Domain[0 1]/Size[64]/Range[0 1 0 1 0 1 0 1]/Decode[0 1 0 1 0 1 0 1]>>

47 0 obj
<</FunctionType 3/Encode[0 1]/Domain[0 1]/Functions[46 0 R]/Bounds[]>>

48 0 obj
<</ColorSpace/DeviceCMYK/Coords[0 0 0 0 0 1]/Function 47 0 R/Extend[true true]/ShadingType 3>>

Here's a hex dump of the stream for object 46 0:

Code:
FF 00 FF 00 FE 00 FE 00 FC 00 FC 00 FA 00 FA 00  ÿ.ÿ.þ.þ.ü.ü.ú.ú.
F8 00 F8 00 F6 00 F6 00 F4 00 F4 00 F2 00 F2 00  ø.ø.ö.ö.ô.ô.ò.ò.
EF 00 EF 00 EC 00 EC 00 EA 00 EA 00 E7 00 E7 00  ï.ï.ì.ì.ê.ê.ç.ç.
E4 00 E4 00 E1 00 E1 00 DD 00 DD 00 DA 00 DA 00  ä.ä.á.á.Ý.Ý.Ú.Ú.
D7 00 D7 00 D3 00 D3 00 D0 00 D0 00 CC 00 CC 00  ×.×.Ó.Ó.Ð.Ð.Ì.Ì.
C9 00 C9 00 C5 00 C5 00 C1 00 C1 00 BE 00 BE 00  É.É.Å.Å.Á.Á.¾.¾.
BA 00 BA 00 B6 00 B6 00 B2 00 B2 00 AE 00 AE 00  º.º.¶.¶.².².®.®.
AA 00 AA 00 A6 00 A6 00 A1 00 A1 00 9D 00 9D 00  ª.ª.¦.¦.¡.¡...
99 00 99 00 94 00 94 00 90 00 90 00 8C 00 8C 00  ™.™.”.”...Œ.Œ.
87 00 87 00 83 00 83 00 7E 00 7E 00 79 00 79 00  ‡.‡.ƒ.ƒ.~.~.y.y.
75 00 75 00 70 00 70 00 6B 00 6B 00 67 00 67 00  u.u.p.p.k.k.g.g.
62 00 62 00 5D 00 5D 00 58 00 58 00 53 00 53 00  b.b.].].X.X.S.S.
4E 00 4E 00 49 00 49 00 44 00 44 00 3F 00 3F 00  N.N.I.I.D.D.?.?.
3A 00 3A 00 35 00 35 00 30 00 30 00 2A 00 2A 00  :.:.5.5.0.0.*.*.
25 00 25 00 20 00 20 00 1B 00 1B 00 15 00 15 00  %.%. . .........
10 00 10 00 0A 00 0A 00 05 00 05 00 00 00 00 00  ................

The other two objects don't have streams.

I never studied functions very closely in Abode's PDF reference. Maybe I should....

(EDIT: These aren't the only functions in the PDF; I just posted a sample of three that seem to relate to each other.)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 297 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group