Subscribe Bookmark RSS Feed

Send Image to Clipboard

Highlighted
ih

Community Trekker

Joined:

Sep 30, 2016

How can I save an image to the clipboard such that it can be pasted into other programs, similar to Copy Graph in Graph Builder?

 

This saves the image as text:

img = Open("$Sample_Images/black rhino footprint.jpg", jpg);
Set Clipboard( img );

 

But I cannot paste this into an email, etc.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz

Super User

Joined:

Jun 23, 2011

Solution

This code is simpler; no new window required.

Names default to here( 1 );

//Get an image from "New image()", "<< Get Picture", etc:
img = New image("$Sample_Images/black rhino footprint.jpg");
pb = Picture Box( img );
pb << Copy Picture;
3 REPLIES
Byron_JMP

Staff

Joined:

Apr 26, 2012

It might be more straightforward to just save the graphic you want and then pick it back up with the other program

//run this again Abrasion.jmp from the sample data

obj=Distribution(
	Continuous Distribution(
		Column( :Abrasion ),
		PpK Capability Labeling( 1 ),
		Customize Summary Statistics( N Missing( 1 ), N Unique( 1 ) )
	)
);
r = obj << Report;
//three ways to get a picture
bb2 = r[border box (2)] <<Get Picture;
bb2 = r[border box (2)] <<Save Capture( "/Users/bywing/Downloads/eraseme.png",png);
bb2 = r[border box (2)] <<Save Picture( "/Users/bywing/Downloads/eraseme.png",png);

I'm interested in trying to get this idea of pasting an graphic to the clipboard and picking it up with something else.

 

I've used this expression to copy a data table to the clipboard:

main menu("Copy With Column Names")

I tried this approach to get the image, but it doesn't seem to work.

bb2 = r[border box (2)] << select;
current window()<<main menu ("Copy");

When I past this, I just get the evaluated expression, not the image.

 

 

ih

Community Trekker

Joined:

Sep 30, 2016

Your Get Picture and Save Picture messages reminded me of Copy Picture, which does work for a picture box.  Leveraging a picture box and copy picture gives the function below.  There must be a more straightforward way though...

Names default to here( 1 );

PicToClipboard = Function( {img},
	win = New Window("temp",
		pb = Picture Box( img )
	);

	pb << Copy Picture;

	win << Close Window();	
);


//Get an image from "New image()", "<< Get Picture", etc: img = New image("$Sample_Images/black rhino footprint.jpg");
//Save it to the clipboard PicToClipboard( img );
pmroz

Super User

Joined:

Jun 23, 2011

Solution

This code is simpler; no new window required.

Names default to here( 1 );

//Get an image from "New image()", "<< Get Picture", etc:
img = New image("$Sample_Images/black rhino footprint.jpg");
pb = Picture Box( img );
pb << Copy Picture;