Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How do I copy an image file as only an image to the clipboard?


  • Please log in to reply
1 reply to this topic
double_jumper
  • Members
  • 2 posts
  • Last active: Mar 11 2017 09:36 PM
  • Joined: 02 Aug 2014
I mean just like when you copy an image selection, or an online pic, or take a screenshot.
I just need a function that uses the filepath to get the image ready to be pasted on editors.
My searches only resulted in functions related to copying files either directly to the destination, or copying only the filepath.
Edit: found a solution using the gdip library:
ImgToClipboard(imagepath){
	pToken := Gdip_Startup()
	Gdip_SetBitmapToClipboard(pBitmap := Gdip_CreateBitmapFromFile(imagepath))
	Gdip_DisposeImage(pBitmap)
	Gdip_Shutdown(pToken)
}


GEV
  • Members
  • 1364 posts
  • Last active:
  • Joined: 23 Oct 2013

I just need a function to get the image ready to be pasted on editors.

 

 

You could save the last copied image in a file:

#Persistent

OnClipboardChange:
 if(A_EventInfo=2)   ; if the Clipboard contains images
{
FileDelete, C:\image saved.clip
ToolTip image saved
FileAppend, %ClipboardAll%, C:\image saved.clip	  ; save image
Sleep 1000
ToolTip
}
return

#v::	  ; paste saved image
ClipSaved := ClipboardAll
Clipboard =
FileRead, Clipboard, *c C:\image saved.clip
ClipWait, 2
Send ^v
clipboard := ClipSaved
return