Generating improved EPS/PDFs for transparent bitmaps before PS/PDF supports transparency
I wonder if you've considered an interim solution to generating better EPS files and PDFs for Inkscape drawings with transparent bitmaps. I would like to run and idea past you. I am unfamiliar with Inkscape from a developers perspective, so it may be worthless. In case it's not, here goes.
If we exclude bitmaps which are rotated or skewed, it seems that one could use Inkscape's SVG -> bitmap capability (demonstrated by the PNG export) to resolve the transparency and generate a resolved bitmap that could be used instead of the original tranparent bitmap when producing the EPS/PDF. If a transparent bitmap covers the rectangle defined by its corners (x1, y1) to (x2,y2), you can calculate the dots per inch of the in the x and y dimension taking into account any scaling applied by the user. Use Inkscape to render a bitmap of the rectangle (x1,y1) to (x2, y2) at the maximum of resolution (perhaps min {300, max {x_resolution, y_resolution}}). Use this bitmap instead of the orignal when creating the PDF.
Of course, this idea can be improved upon. For example during the bitmap rendering phase, it would be better to render only the bitmap and elements below it (i.e., things that could actually appear in the transparent parts of the bitmap and not things above). If SVG's bitmap renderer can have different x and y resolutions, match the original bitmaps x and y resolutions. Alternatively, you could render the bitmap at a higher resolution to make sure the background elements that show through the transparent parts appear smooth at reasonable printing resolutions.
I suppose you could even handle scaled, rotated and skewed bitmaps by rendering at high resolution a box that includes the whole scaled, rotated and/or skewed bitmap. Then take the resolved bitmap and undo the scale, skew and/or rotation to generate an unperturbed bitmap that when scaled, rotated and/or skewed will produce the contents that the renderer produced. I am guessing that in 90% of the situations, bitmaps aren't rotated or skewed, so it may not be worth solving the general problem.
Well, what do you think? I recently made a poster with a radial gradient as the background and several logos (tranparent bitmaps) were on top of the gradient. I ended up exporting as a high resolution PNG, converting to TIFF and then converting TIFF2PDF. Inkscape looks like a fine program.
Tom
Tom,
I think what you're talking about is definitely possible, we've talked about it before. I think one of the hardest cases is dealing with complex paths with transparent gradients -- but it is solvable too. I don't believe that anyone is currently working on it though. If you'd like to, I can give you some pointers about where to start looking in the code.
--Ted
On Thu, 2005-09-29 at 09:29 -0700, Tom Epperly wrote:
I wonder if you've considered an interim solution to generating better EPS files and PDFs for Inkscape drawings with transparent bitmaps. I would like to run and idea past you. I am unfamiliar with Inkscape from a developers perspective, so it may be worthless. In case it's not, here goes.
If we exclude bitmaps which are rotated or skewed, it seems that one could use Inkscape's SVG -> bitmap capability (demonstrated by the PNG export) to resolve the transparency and generate a resolved bitmap that could be used instead of the original tranparent bitmap when producing the EPS/PDF. If a transparent bitmap covers the rectangle defined by its corners (x1, y1) to (x2,y2), you can calculate the dots per inch of the in the x and y dimension taking into account any scaling applied by the user. Use Inkscape to render a bitmap of the rectangle (x1,y1) to (x2, y2) at the maximum of resolution (perhaps min {300, max {x_resolution, y_resolution}}). Use this bitmap instead of the orignal when creating the PDF.
Of course, this idea can be improved upon. For example during the bitmap rendering phase, it would be better to render only the bitmap and elements below it (i.e., things that could actually appear in the transparent parts of the bitmap and not things above). If SVG's bitmap renderer can have different x and y resolutions, match the original bitmaps x and y resolutions. Alternatively, you could render the bitmap at a higher resolution to make sure the background elements that show through the transparent parts appear smooth at reasonable printing resolutions.
I suppose you could even handle scaled, rotated and skewed bitmaps by rendering at high resolution a box that includes the whole scaled, rotated and/or skewed bitmap. Then take the resolved bitmap and undo the scale, skew and/or rotation to generate an unperturbed bitmap that when scaled, rotated and/or skewed will produce the contents that the renderer produced. I am guessing that in 90% of the situations, bitmaps aren't rotated or skewed, so it may not be worth solving the general problem.
Well, what do you think? I recently made a poster with a radial gradient as the background and several logos (tranparent bitmaps) were on top of the gradient. I ended up exporting as a high resolution PNG, converting to TIFF and then converting TIFF2PDF. Inkscape looks like a fine program.
Tom
This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Sure, send the pointers. Do you have a guess how long such a change would take to make? I would like to know what I am getting myself into if I decide to attempt to do this.
Tom
Ted Gould wrote:
Tom,
I think what you're talking about is definitely possible, we've talked about it before. I think one of the hardest cases is dealing with complex paths with transparent gradients -- but it is solvable too. I don't believe that anyone is currently working on it though. If you'd like to, I can give you some pointers about where to start looking in the code.
--Ted
On Thu, 2005-09-29 at 09:29 -0700, Tom Epperly wrote:
I wonder if you've considered an interim solution to generating better EPS files and PDFs for Inkscape drawings with transparent bitmaps. I would like to run and idea past you. I am unfamiliar with Inkscape from a developers perspective, so it may be worthless. In case it's not, here goes.
If we exclude bitmaps which are rotated or skewed, it seems that one could use Inkscape's SVG -> bitmap capability (demonstrated by the PNG export) to resolve the transparency and generate a resolved bitmap that could be used instead of the original tranparent bitmap when producing the EPS/PDF. If a transparent bitmap covers the rectangle defined by its corners (x1, y1) to (x2,y2), you can calculate the dots per inch of the in the x and y dimension taking into account any scaling applied by the user. Use Inkscape to render a bitmap of the rectangle (x1,y1) to (x2, y2) at the maximum of resolution (perhaps min {300, max {x_resolution, y_resolution}}). Use this bitmap instead of the orignal when creating the PDF.
Of course, this idea can be improved upon. For example during the bitmap rendering phase, it would be better to render only the bitmap and elements below it (i.e., things that could actually appear in the transparent parts of the bitmap and not things above). If SVG's bitmap renderer can have different x and y resolutions, match the original bitmaps x and y resolutions. Alternatively, you could render the bitmap at a higher resolution to make sure the background elements that show through the transparent parts appear smooth at reasonable printing resolutions.
I suppose you could even handle scaled, rotated and skewed bitmaps by rendering at high resolution a box that includes the whole scaled, rotated and/or skewed bitmap. Then take the resolved bitmap and undo the scale, skew and/or rotation to generate an unperturbed bitmap that when scaled, rotated and/or skewed will produce the contents that the renderer produced. I am guessing that in 90% of the situations, bitmaps aren't rotated or skewed, so it may not be worth solving the general problem.
Well, what do you think? I recently made a poster with a radial gradient as the background and several logos (tranparent bitmaps) were on top of the gradient. I ended up exporting as a high resolution PNG, converting to TIFF and then converting TIFF2PDF. Inkscape looks like a fine program.
Tom
This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
On Fri, 2005-09-30 at 09:49 -0700, Tom Epperly wrote:
Sure, send the pointers. Do you have a guess how long such a change would take to make? I would like to know what I am getting myself into if I decide to attempt to do this.
Sorry to take so long on this, it got lost in my mail.
Probably the best place to start is in the postscript printer extension. It houses some of the postscript code, but my understanding is that unfortunately not all of it. I know that Kees was having problems upgrading the GNOME-Print driver because some of the interface involved taking in Postscript operators. But, I believe that there is already the feature to render the whole page as a bitmap in there. It is none the less, a good place to start.
http://inkscape.org/doc/doxygen/html/classInkscape_1_1Extension_1_1Internal_...
As far as Lauris previously implementing it, I don't remember that. And the Postscript output has remained largely the same from Sodipodi. Lauris designed the Print Extension interface, all I did is translate it in to C++. The other feature that has been added deals with text, but I don't remember any regressions from that. I do believe that Lauris was involved in the beginnings of GNOME-Print, so it may have worked at some time through that interface.
Tom, it's hard to say how long it will take. If I were going to guess, I'd say a good 20 programming hours for me. You've got the disadvantage that you need to learn more about the internals than I do... I also don't know what your experience is.
While I'd agree with Bulia that I would be more excited if you were saying that you wanted to make PDF 1.5 output, updates the Postscript output will be accepted. I think that quality printing support is a place where Inkscape is currently lacking.
--Ted
For what it's worth, Lauris implemented this in Sodipodi a long time ago, although he didn't get as far as matching the DPI of the generated bitmaps to the output DPI.
Check out some of the early Sodipodi news items.
I don't know what happened to this code after the fork...
-mental
On 9/29/05, Tom Epperly <tepperly@...1012...> wrote:
I wonder if you've considered an interim solution to generating better EPS files and PDFs for Inkscape drawings with transparent bitmaps. I would like to run and idea past you. I am unfamiliar with Inkscape from a developers perspective, so it may be worthless. In case it's not, here goes.
As far as I understand from your description, what you suggest is changing the way we treat bitmap objects on export to PS - is this correct? If so it is possible, but it will fix only a small part of all problems with transparency in PS. Regular vector objects with transparency are much more common than transparent bitmaps.
As I already said here, my personal view is that it's not worth it to spend effort on improving PS export with regard to transparency (any such improvements are bound to be more or less hacks). Instead, it's better to spend the same resources on supporting PDF with native transparency.
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org
bulia byak wrote:
On 9/29/05, Tom Epperly <tepperly@...1012...> wrote:
I wonder if you've considered an interim solution to generating better EPS files and PDFs for Inkscape drawings with transparent bitmaps. I would like to run and idea past you. I am unfamiliar with Inkscape from a developers perspective, so it may be worthless. In case it's not, here goes.
As far as I understand from your description, what you suggest is changing the way we treat bitmap objects on export to PS - is this correct? If so it is possible, but it will fix only a small part of all problems with transparency in PS. Regular vector objects with transparency are much more common than transparent bitmaps.
As I already said here, my personal view is that it's not worth it to spend effort on improving PS export with regard to transparency (any such improvements are bound to be more or less hacks). Instead, it's better to spend the same resources on supporting PDF with native transparency.
I did a little WWW searching, and I see that "PostScript 3 technology delivers support for transparent artwork in PDF 1.4 and 1.5 and support for JPEG 2000 and layers in PDF 1.5." I know Postscript up to level 2, but I can't seem to find any detailed (non-marketing) descriptions of what operators they added in level 3.
Tom
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org
On 9/30/05, Tom Epperly <tepperly@...1012...> wrote:
I did a little WWW searching, and I see that "PostScript 3 technology delivers support for transparent artwork in PDF 1.4 and 1.5 and support for JPEG 2000 and layers in PDF 1.5." I know Postscript up to level 2, but I can't seem to find any detailed (non-marketing) descriptions of what operators they added in level 3.
Yeah, marketing descriptions are generally misleading, but this one is particularly confusing. I believe what they meant to say is that true transparency is in PDF 1.4+, and that is somehow based on PS3, so by some twist, PS3 can be said to "deliver" it even though it does not support it itself.
Anyway, to get the manual for PS3, google for plrm.pdf. From when I read it, I remember they added some sort of bitmap transparency masks for bitmaps, but not even flat semi-transparency for regular vector objects. Which, to me, means it's almost useless.
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org
On Friday 30 September 2005 21:06, bulia byak wrote:
On 9/30/05, Tom Epperly <tepperly@...1012...> wrote:
I did a little WWW searching, and I see that "PostScript 3 technology delivers support for transparent artwork in PDF 1.4 and 1.5 and support for JPEG 2000 and layers in PDF 1.5." I know Postscript up to level 2, but I can't seem to find any detailed (non-marketing) descriptions of what operators they added in level 3.
Yeah, marketing descriptions are generally misleading, but this one is particularly confusing. I believe what they meant to say is that true transparency is in PDF 1.4+, and that is somehow based on PS3, so by some twist, PS3 can be said to "deliver" it even though it does not support it itself.
Anyway, to get the manual for PS3, google for plrm.pdf. From when I read it, I remember they added some sort of bitmap transparency masks for bitmaps, but not even flat semi-transparency for regular vector objects. Which, to me, means it's almost useless.
The latest PS3, 3017, has a lot more transparency support, possibly even full support. However, when you only support PS3, you then must have a way of converting to level 1 and 2, which isnt hard using ghostscript, but then you also require a decent level of ghostscript.
Craig
"Tom" == Tom Epperly <tepperly@...1012...> writes:
Tom> but I can't seem to find any detailed Tom> (non-marketing) descriptions of what operators they added in Tom> level 3.
Appendix A.1 of the PLRM¹ has that info.
-JimC
¹ I don't have aproper BibTeX entry, but Google shows these links:
http://www.adobe.com/products/postscript/pdfs/PLRM.pdf http://partners.adobe.com/asn/developer/PDFS/TN/PLRM.pdf
although only the former is Content-Type: application/pdf.
participants (6)
-
unknown@example.com
-
bulia byak
-
Craig Bradney
-
James Cloos
-
Ted Gould
-
Tom Epperly