File Exchange

image thumbnail


version (3.79 KB) by jiro
Copy and paste image data to and from system clipboard.


Updated 23 Mar 2017

View Version History

View License

IMCLIPBOARD behaves very much like MATLAB's "CLIPBOARD" function, but it works on image data. You can paste image data from the clipboard to a MATLAB array, and copy MATLAB image data to the clipboard.
From HELP:
IMCLIPBOARD('copy', IMDATA) sets the clipboard content to the image represented by IMDATA. IMDATA must be MxN grayscale (double, uint8, uint16), MxN black and white (logical), MxNx3 true color (double, uint8, uint16)
IMCLIPBOARD('copy', X, MAP) sets the clipboard content to the image data represented by indexed image X with colormap MAP. X must be MxN matrix (double, uint8, uint16) and MAP must be Px3 (double).

IMDATA = IMCLIPBOARD('paste') returns the current image content in the clipboard as a true color image (MxNx3 uint8).

[X, MAP] = IMCLIPBOARD('paste') returns the current image content in the clipboard as an indexed color image.

IMCLIPBOARD('paste') displays the image in a new figure window.

[...] = IMCLIPBOARD('paste', FILENAME) saves the image as FILENAME. FILENAME must be a name to one of the following image formats: JPG, GIF, BMP, PNG, TIF.

Note: IMCLIPBOARD requires Java on all platforms.

Cite As

jiro (2021). IMCLIPBOARD (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

Luca Amerio

Ran Klein


This is great in Windows, indeed. Does anyone have this working on OS X? I'm attempting to modify it for OS X... it appears to get the clipboard object but it's unhappy about getData. Help is appreciated! Thanks.

Ilya Belevich

Norman Koren


Perfect tool for automatically moving images to the clipboard so that they can be copied into Word etc.

Daeyong Kim

It's great.

Will Reeves



Matlab's default Figure > Copy option is vastly improved witht he following,
imclipboard('copy', export_fig('r', 190, 'format', 'png'));
This is useful for copying a figure into Outlook or Word.
[credit for this solution to by Oliver Woodford not me!]


Whoops - the problem was with how I was calling it. It works great from within a GUI as well. I'm using it to copy an image of my GUI to the clipboard. This function gives a nicer image than print(gcbf, '-dmeta').



It does what it says. However, when I call it from within a GUI, the next callback that is activated (by changing a number in a text box or clicking a button), does not execute. As an example, I get the following warning for my GUI called ProductViewer. I can generate a similar error by activating any control in the GUI.

Warning: Error occurred while evaluating listener callback.
> In graphics\private\clo at 83
In cla at 29
In newplot>ObserveAxesNextPlot at 125
In newplot at 74
In imagesc at 21
In ProductViewer>PlotFrame at 629
In ProductViewer>edit_row_min_Callback at 514
In gui_mainfcn at 96
In ProductViewer at 87
In @(hObject,eventdata)ProductViewer('edit_row_min_Callback',hObject,eventdata,guidata(hObject))

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!