[cairo] Embedding jpeg in pdf

Adrian Johnson ajohnson at redneon.com
Mon Jul 14 16:21:10 PDT 2008


Jeff Muizelaar wrote:
> On Mon, Jul 14, 2008 at 02:23:30PM +0000, Benjamin Otte wrote:
>> handling library.
>> Anyway, there's some problems I have with not depending on libjpeg:
>> 1) I think most backends that support JPEG only support a subset. I guess you'd
>> need libjpeg to figure out if the current JPEG data is supported anyway. (The
>> same would likely be true for other image formats, too.)
> 
> This is a interesting issue. The only difference I know about in level
> of support is progressive JPEGs. They are not supported by postscript
> but are supported by PDF 1.3+. I don't think it would be too hard to
> determine whether a jpeg is progressive or not without depending on
> libjpeg. I also assume GDI does not support progressive JPEG but I
> haven't been able to find any information confirming that.
> 
> As for confirming that the JPEG data is actually valid I think it makes
> sense to punt that to the application. Applications will already need to
> do this anyways.

The Adobe technical note at [1] has a list of which jpeg markers are 
supported by PostScript Level 2. Checking for supported markers in cairo 
is easy to do. In the patch I wrote for adding jpeg support without 
libjpeg there is a function [2] for extracting the jpeg parameters such 
as width and height. It would be easy to extend this to check for the PS 
Level 2 supported markers so that the PS surface can fallback to using 
LZW if the jpeg is not supported.

[1] http://partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf

[2] 
http://gitweb.freedesktop.org/?p=users/ajohnson/cairo.git;a=blob;h=75dc0bf22c9f63d3c22691414336858f5780a868;hb=d8069197d9473766ad541696ac13eb1e17d57ffc;f=src/cairo-jpeg-info.c




More information about the cairo mailing list