remling has asked for the wisdom of the Perl Monks concerning the following question:

I have searched high and low for a method for saving an image (png, gif, or jpg, created with GD) to the window's Clipboard. I can place text w/o issue but have not come up with a way to save an image. Any advice would be appreciated!
  • Comment on Copy an image to the Clipboard, Windows

Replies are listed 'Best First'.
Re: Copy an image to the Clipboard, Windows
by BrowserUk (Patriarch) on Oct 16, 2014 at 10:39 UTC

    Neither do exactly what you want to do, but Re: capture what's on the screen & Windows screengrab with GD both manipulate images with GD and Win32::Clipboard.

    The upshot is that the latter only handles .BMP format and the former doesn't; so you'd have to play games to get the two to work together.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Copy an image to the Clipboard, Windows
by karlgoethebier (Abbot) on Oct 16, 2014 at 10:01 UTC

    Perhaps Win32::Clipboard might help?

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Win32::Clipboard only handles .BMP image type; and GD doesn't.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Mmh, perhaps using ImageMagick's convert might be a (inconvenient) workaround?

        «The Crux of the Biscuit is the Apostrophe»

        Yes, i just saw this. Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

Re: Copy an image to the Clipboard, Windows
by ww (Archbishop) on Oct 16, 2014 at 11:52 UTC
    Sounds like an XY problem to me.

    What's your real goal? What's your process?

    Why not simply save the image(s) (.png, .gif or .jpg or .bmp if necessary) directly to disk and then manipulate them with an appropriate tool.



    If I've misconstrued your question or the logic needed to answer it, I offer my apologies to all those electrons which were inconvenienced by the creation of this post.
      I have a Tk gui that generates several plots and graphs using the Tk::Canvas. Currently, I allow users to save .gifs, .pngs, .jpegs, etc by converting the canvas to GD, then dump to disk. Several users have asked that I allow them to CNTRL-C the canvas image (copy to clipboard) so they can paste the image into an email, spreadsheet, whatever. It's really more of a convenience... they already have the ability to get the image from the disk save.
        Ok.... so XY problem guess was not PRECISELY on-target; now sounds (to this non-user of Tk:...) like a tradeoff between cost/difficulty (as mentioned by other responders) and your (presumed) desired to please the users.

        But unless they're the source of big$ or major gratification, I probably would not bother!



        If you didn't program your executable by toggling in binary, it wasn't really programming!

        depending on the machine they are using, maybe you can tell them to try clipx? i am pretty sure that clipx does this (copy images to clipboard) and it also allows you to copy multiple entries at the same time. maybe the users installing clipx could be a solution