Is there any way to paste transparent image to photoshop via clipboard?
I tried to use registered "PNG" format, but it seems like photoshop does not support it (opposite to MSOffice 2007 and GIMP). Usage of CF_DIB does not preserve alpha channel in photoshop.
NOTE: I used WinApi to perform such things
So I got fed up with this annoyance and made a workaround.
There are two pieces to it:
The AutoHotKey script checks if Photoshop is currently active, and if so it intercepts the Ctrl
+V
key combination, and then it runs the utility.
If the utility saved an image to %TEMP%\clip.png
, the Shift
+Ctrl
+F12
key combination is sent to Photoshop, which I have mapped to a Photoshop Action to place the clip.png
file into the currently open document.
If the utility did not save the image, the standard Ctrl
+V
key combo is sent to Photoshop and a standard paste is performed.
All the source code is available here: https://github.com/SilverEzhik/ClipboardToPNG, and the utility can be downloaded here: https://github.com/SilverEzhik/ClipboardToPNG/releases
To create the Photoshop Action, just make a new action with the key combination mapped to Shift+Ctrl+F12 (or change the combination in the script file), and then while recording, go to File
> Place Embedded...
, and paste %TEMP%\clip.png
in the file name field.
The source code for the AHK script is provided below - if you haven't used AutoHotKey before, install it, then save the code to a filename.ahk
file to the same directory as the ClipboardToPNG.exe utility, and then just run it.
DoPhotoshopPaste() {
RunWait, %A_ScriptDir%\ClipboardToPNG.exe ; run utility, wait for it to complete
if (ErrorLevel == 0) { ; if error code is 0
SendEvent, +^{F12} ; press Shift+Ctrl+F12 to run the designated Photoshop action to paste
}
else {
SendEvent, ^v ; else, just perform a standard paste.
}
}
#IfWinActive ahk_exe Photoshop.exe ; only activate this hotkey when photoshop is active
^v::DoPhotoshopPaste()
#IfWinActive
Unfortunately, Photoshop has yet to assist in the "copy-paste" of pngs from an external source into a page without a black bringing a background. The only way that I know of is to save the file and then open it in Photoshop. From there, a "copy-paste" should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With