Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Paste image directly into V7 notebook on Linux/X11

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99049] Re: Paste image directly into V7 notebook on Linux/X11
  • From: Francesco <b.gatessucks at gmail.com>
  • Date: Sat, 25 Apr 2009 04:50:13 -0400 (EDT)
  • References: <gsrqt1$ral$1@smc.vnet.net>

Tested with pdf files from Okular, jpg images from GIMP.
Much needed, many thanks.
-Francesco



jkerrb at gmail.com wrote:
> 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
> 


  • Prev by Date: Re: MatrixPlot with color range bar
  • Next by Date: Re: Brace, bracket pretty format needed
  • Previous by thread: Paste image directly into V7 notebook on Linux/X11
  • Next by thread: Re: "formatting notebook contents" messages, why so many in