[cairo] Re: Embeding JPG in PDF

Bill Spitzak spitzak at d2.com
Fri Jan 12 12:52:33 PST 2007



Behdad Esfahbod wrote:
> On Wed, 2007-01-10 at 08:36 -0500, Kristian Høgsberg wrote:
>> The topic isn't about encoding images lossyly to jpeg, it's about
>> images that are already stored as jpeg and can be directly embedded in
>> the pdf as such.  It's a valid use case, but it's not clear how the
>> API should look. 
> 
> This was the topic that started the thread.  But since, I've convinced
> myself that we need to allow embedding an image surface into PDF in JPG
> instead of PNG too, for sole size purposes.

That can be done by the PDF output cairo_t with no additions to Cairo. 
It just has to include a converter to jpeg, and the necessary controls 
and intelligence to identify when to use it.

However the original problem is not solved. Even with the above, a 
program reading a jpeg in and drawing it on a pdf surface using cairo 
will result in the jpeg being decompressed and then recompressed. This 
is lossy and slow. The only way it will happen is if the pdf surface can 
look at the surface it is copying from and identify that it can get raw 
jpeg data from it.



More information about the cairo mailing list