Bug 692932

Summary: Save the clipboard as an image
Product: MuPDF Reporter: Palmer Dabbelt <palmem>
Component: mupdfAssignee: MuPDF bugs <mupdf-bugs>
Status: RESOLVED DUPLICATE    
Severity: enhancement CC: tor.andersson
Priority: P4    
Version: unspecified   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: Writes the clipboard to "mupdf.pnm" when the user presses 'i'
Writes the clipboard to "mupdf.pnm" when the user presses 'p'
Writes the clipboard to "mupdf.pnm" when the user presses 'p'

Description Palmer Dabbelt 2012-03-17 22:03:35 UTC
Created attachment 8431 [details]
Writes the clipboard to "mupdf.pnm" when the user presses 'i'

Okular has a unique feature that allows one to save the clipboard contents to an image (as opposed to copying it as text).  This is particularly useful when one wants to quickly screenshot only part of a page.

I've attached a patch against the current git head that enables the same functionality in MuPDF.  My implementation isn't so great (it just writes a pnm in the current working directory whenever the user hits 'i'), but hopefully it at least illustrates the feature request well.  I just learned about MuPDF (so needless to say this is my first attempt at hacking on the source :)) so I'm not sure if this is up to your coding standards -- if it's not I'll try and fix it!  The patch compiles on Gentoo Linux for me.

I think the best implementation would be to write the current page out as a PDF with a bounding box that only shows the selected area, but I'm not sure if that's even possible.  A secondary implementation would be to write a PNG instead of a PNM, which I think should be quite possible (it's just compressing what I do now, which I think should be easy using the fz_ calls).

If anyone wants to easily try out my change on Gentoo I've made an ebuild that snapshots the current git head and applies my patch.  It's in my overlay at <https://sourceforge.net/u/palmerdabbelt/portage/>.
Comment 1 Palmer Dabbelt 2012-04-10 01:49:59 UTC
Created attachment 8518 [details]
Writes the clipboard to "mupdf.pnm" when the user presses 'p'

I've updated the patch to apply against the current git head as of right now (ed187a8bd9340788bca2ee84b93c965f38c8821f).

The only required change was to change the key to 'p', as 'i' was used by an update.
Comment 2 Palmer Dabbelt 2012-04-23 01:04:24 UTC
Created attachment 8543 [details]
Writes the clipboard to "mupdf.pnm" when the user presses 'p'

I've updated my patch to the current git head.  The only conflict was in the help text.
Comment 3 Tor Andersson 2014-05-21 06:13:54 UTC

*** This bug has been marked as a duplicate of bug 691330 ***