<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:231963137;
        mso-list-type:hybrid;
        mso-list-template-ids:-150430288 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l1
        {mso-list-id:721371686;
        mso-list-type:hybrid;
        mso-list-template-ids:-1153657786 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l2
        {mso-list-id:1193686794;
        mso-list-type:hybrid;
        mso-list-template-ids:-57091076 67698711 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l2:level1
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hi,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This is my first post, so bear with me, and take my
suggestions lightly. I realize Cairo probably is and has been trying to take a
different path than what i’m suggesting below – i just hope you can
see through what i’m trying to say. There are so many uses for Cairo, and
i see other libraries can be used to support certain functions – however some
things belong in the same place. What i’m using Cairo for a.t.m. is a web
based, template based PDF merging/generator system that takes images (jpegs),
other pdfs, as sources, as well as allowing text input (pango), vector drawing
(cairo) etc etc.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>So, if you are going to implement jpeg support in cairo to
reduce pdf file sizes, why not go full out and implement it like PNG support?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Example functions to back my suggestion:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>cairo_image_surface_create_from_jpeg() – to create a
image surface with the jpeg data attached.<o:p></o:p></p>
<p class=MsoNormal>cairo_surface_write_to_jpeg() – to write any surface
to file as jpeg.<o:p></o:p></p>
<p class=MsoNormal>cairo_surface_get_data() – retrieves data in format
specified in function below, default being RAW. If the surface doesn’t
already have an up to date compressed version of the image data, it will be
compressed to said format.<o:p></o:p></p>
<p class=MsoNormal>cairo_surface_set_output_format(enum FORMAT) – sets default
output format for cairo_paint() and cairo_surface_get_data(), like JPEG/PNG/RAW<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l2 level1 lfo3'><![if !supportLists]><span
style='mso-list:Ignore'>a)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Internally, jpeg buffer will be separate from image
buffer, and jpeg will only be UNCOMPRESSED if one of the following is true:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l1 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Image data is being changed (painting, drawing,
filling, etc) – jpeg will be uncompressed to image buffer before changes
applied<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l1 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Jpeg surface is being painted to a surface that doesn’t
support jpeg data<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l2 level1 lfo3'><![if !supportLists]><span
style='mso-list:Ignore'>b)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Similarly, when one of the following is true, image
data will be (RE)COMPRESSED to jpeg:<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo2'><![if !supportLists]><span
style='mso-list:Ignore'>1)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>image surface is flagged with
cairo_surface_set_output_format(JPEG) and painted to for example a PDF<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo2'><![if !supportLists]><span
style='mso-list:Ignore'>2)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>image surface is saved with cairo_surface_write_to_png/jpeg()<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo2'><![if !supportLists]><span
style='mso-list:Ignore'>3)<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>image surface is extracted with cairo_surface_get_data()
and the output format is set to JPEG and any embedded jpeg data is not
up-to-date (ref a1).<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This way, you can both use cairo to embed jpegs to pdfs at
no recompression cost, since image surface will not have changed – while also
allow getting images from other sources and add them to a pdf as JPEG.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>I realize You could put much of this responsibility on to
the users, but I see it being much easier to use Cairo if the support was built
in – the only user change needed to support jpegs would be to use the
above mentioned functions to load/save jpegs.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>If necessary, make it optional. Go with the default of only
jpeg data attachment and no re/compression – but allow for –with-jpeglib
for those who needs it.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>PS. If going in this direction is an option,
cairo_surface_write_to_png/jpeg would be obsolete with
cairo_surface_set_output_format(), and all could be replaced with one function;
cairo_surface_write_to_file()<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>PPS. Please change PDF support so it allows memory-only surfaces
:)<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Kind regards,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Michael S<o:p></o:p></p>
</div>
</body>
</html>