Bug 690943 - PNG alpha output from pdfdraw
Summary: PNG alpha output from pdfdraw
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: PC Linux
: P4 enhancement
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-21 09:05 UTC by Chris Wolfe
Modified: 2010-07-19 21:50 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
pdfdraw-1-extensions.patch (1.46 KB, patch)
2009-11-21 09:06 UTC, Chris Wolfe
Details | Diff
pdfdraw-2-refactor.patch (3.67 KB, patch)
2009-11-21 09:07 UTC, Chris Wolfe
Details | Diff
pdfdraw-3-libpng.patch (3.91 KB, patch)
2009-11-21 09:07 UTC, Chris Wolfe
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Wolfe 2009-11-21 09:05:35 UTC
I have some TikZ/PGF graphics which are being published both as a PDF and as web
graphics. The diagrams themselves have transparent backgrounds, but wind up
opaque thanks to pdfdraw's PNM-P6 output.

Did some refactoring and added the code this morning. The following patches work
for me with a variety of PDF samples (on Ubuntu hardy, libpng12). Source should
be portable, but LINKLIBS will need tweaking for Windows.

Encountered a glitch where rendertreeover seems to blend with the transparent
background. Have not actually read the fitz API, so this could be expected.

Patches are against Nov 20 03:57:46 EST 2009.
Comment 1 Chris Wolfe 2009-11-21 09:06:39 UTC
Created attachment 5699 [details]
pdfdraw-1-extensions.patch

pdfdraw: tweaked extension recognition and added detection for future output
formats.
Comment 2 Chris Wolfe 2009-11-21 09:07:15 UTC
Created attachment 5700 [details]
pdfdraw-2-refactor.patch

pdfdraw: extracted more generic drawgraphics routine from drawpnm.
Comment 3 Chris Wolfe 2009-11-21 09:07:47 UTC
Created attachment 5701 [details]
pdfdraw-3-libpng.patch

pdfdraw: added PNG output support, with transparent backgrounds.
  
Converted file output to stdio, since libpng supports it natively. As a result,
the mode of created output files is no longer masked to 0666.
Comment 4 Tor Andersson 2010-01-17 06:54:26 UTC
Thanks, but MuPDF does not need yet another library dependency.
We use pnmtopng if we want PNG output from pdfdraw.
Comment 5 Chris Wolfe 2010-01-17 07:20:00 UTC
Same as I was using previous to needing alpha support.

You could probably add P7 support to get alpha support without the library dep.
For my purposes needing netpbm is more annoying than libpng, so will stick with
the patched version.

Had not noticed that you folks do commercial licensing on the side. As such,
those patches are useless for you anyway. Sorry about that.
Comment 6 Tor Andersson 2010-01-17 07:36:48 UTC
We generally use PNM files internally for regression testing and such, but adding P7 support as well as 
grayscale output is definitely worth considering.
Comment 7 Ray Johnston 2010-01-17 10:11:09 UTC
Having alpha output (either pngalph or P7) is definitely worth having and is
critical for some applications. I think this is part of fleshing out mupdf as
a useful tool. Reopening as an enhancemnt request.
Comment 8 Tor Andersson 2010-07-19 21:50:52 UTC
The rewritten pdfdraw tool now provides both PAM and PNG output, with or without alpha channel. If you ask for output with an alpha channel, the page background will be transparent instead of white.