Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Paste image directly into V7 notebook on Linux/X11

5 views
Skip to first unread message

jke...@gmail.com

unread,
Apr 24, 2009, 3:48:49 AM4/24/09
to
Hi,

Yesterday I called Wolfram Research to find out how to paste images
into a version 7 notebook directly from the X11 clipboard on Linux.
The tech stated that this is feature is supported only on windows and
mac, not linux. So I implemented it myself. Here's how:

I'm running KDE4.2, and Klipper does not paste image data, so dbus is
not an option. I settled on using Qt: you will need the command
"getclipboardimage" installed on your $PATH (Qt 4.4 source code and
instructions available at http://www.phys.ucalgary.ca/~burchill).
Perhaps someone could suggest how to do this from perl or python,
etc...

Adding the "Paste Image" to the edit menu involves editing a user-copy
of $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/
MenuSetup.tr. Caution: a typo in this file can break mathematica.

Add the following between the &Paste and Clea&r\tDelete menu items:

MenuItem["Paste &Image",
KernelExecute[{Module[{tmpFile, image, file},
tmpFile = ToFileName
[$TemporaryDirectory, "clipboardimagefileformathematica.png"];
DeleteFile[FileNames[tmpFile]];
file = Import["!getclipboardimage "
<> tmpFile, "Lines"];
If[Length[file] > 0, image = Import
[file[[1]], "Image"];
If[Head[image] === Image,
NotebookWrite[InputNotebook[],
Cell[BoxData
[ToBoxes@image],"Output"]]]];]}],
MenuKey["V", Modifiers->{"Control"}], MenuEvaluator-
>Automatic],

Restart mathematica. Try it out by opening a PDF file, selecting an
image and copying it to the clipboard. In a notebook select "Paste
Image" from the Edit menu. This inserts the image in-line.

Cheers,
JB

Francesco

unread,
Apr 25, 2009, 4:49:37 AM4/25/09
to
Tested with pdf files from Okular, jpg images from GIMP.
Much needed, many thanks.
-Francesco
0 new messages