Open RetroTechCorner opened 6 months ago
Is the image a PNG? I believe at the moment only PNG format is supported.
It seems it also stores some metadata in the few first bytes and it seems it's this for the screenshot: 0xC2 0xAB 0x63 0x6C 0x61 0x73 0x73 0x20 0x50 0x4E 0x47 0x66 0xC2 0xBB 0x3A 0xC2 0xAB 0x64 0x61 0x74 0x61 0x20
The rest is a png (or PNGf to be precise). Here's how pillow handles that:
def grabclipboard():
if sys.platform == "darwin":
fh, filepath = tempfile.mkstemp(".png")
os.close(fh)
commands = [
'set theFile to (open for access POSIX file "'
+ filepath
+ '" with write permission)',
"try",
" write (the clipboard as Β«class PNGfΒ») to theFile",
"end try",
"close access theFile",
]
script = ["osascript"]
for command in commands:
script += ["-e", command]
subprocess.call(script)
im = None
if os.stat(filepath).st_size != 0:
im = Image.open(filepath)
im.load()
os.unlink(filepath)
return im
But I think stripping first few bytes would work as well (rather that calling osascript) pypaperclip also seems to be able to do it https://github.com/asweigart/pyperclip
I'm happy to review a PR for making this functionality more robust
I'm certainly not skilled enough to create the PR but hopefully somebody will pick it up :)
@RetroTechCorner did you brew install pngpaste
? I was getting the same error until I installed that.
Not sure if I should be creating a new issue for this or not as it is related.
I can copy (using cmd + c
) a PNG image while inside Finder and use the ObsidianPasteImg
to paste it into a README or other .md file, but instead of seeing the actual image, I just see the PNG file icon, rather than the actual image itself:
If you want me to create a new issue for this, as it is a different but related issue, let me know and I'd be happy to do so.
I'm running into the original issue. I get "There is no image data in the clipboard".
I've confirmed that I've copied a png, and I've run brew install pngpaste
and confirmed it's in my Path (I can run pngpaste on the command line and get the usage suggestions back)
Let me know if you have any suggestions or if there's any other info I can provide to help debug this!
I'm running into the original issue. I get "There is no image data in the clipboard".
I've confirmed that I've copied a png, and I've run
brew install pngpaste
and confirmed it's in my Path (I can run pngpaste on the command line and get the usage suggestions back)Let me know if you have any suggestions or if there's any other info I can provide to help debug this!
What version are you using? Is it the latest commit or the latest release? I had the same issue while using the latest release. Updating to the latest commit by removing the version = *
entry from the plugin config solved this issue for me.
Not sure if I should be creating a new issue for this or not as it is related.
I can copy (using
cmd + c
) a PNG image while inside Finder and use theObsidianPasteImg
to paste it into a README or other .md file, but instead of seeing the actual image, I just see the PNG file icon, rather than the actual image itself:
If you want me to create a new issue for this, as it is a different but related issue, let me know and I'd be happy to do so.
@Mo0rBy have you managed to solve this issue? I'm running into this issue too and I'm struggling to find a fix for it. I believe this might be related to pngpaste
itself because it reproduces not only when running ObsidianPasteImg
, but when running pngpaste dummy.png
in the terminal directly as well.
Not sure if I should be creating a new issue for this or not as it is related. I can copy (using
cmd + c
) a PNG image while inside Finder and use theObsidianPasteImg
to paste it into a README or other .md file, but instead of seeing the actual image, I just see the PNG file icon, rather than the actual image itself: If you want me to create a new issue for this, as it is a different but related issue, let me know and I'd be happy to do so.@Mo0rBy have you managed to solve this issue? I'm running into this issue too and I'm struggling to find a fix for it. I believe this might be related to
pngpaste
itself because it reproduces not only when runningObsidianPasteImg
, but when runningpngpaste dummy.png
in the terminal directly as well.
I've managed to get it working. My solution was that instead of pressing cmd+c
in Finder to open the image in Preview and then press cmd+c
in Preview.
@mccuna thanks for the followup! I hadn't tried to paste an image since commenting, but it's now working for me (my lazy lock file is pointed at commit ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b
)
π Describe the bug
After taking a screenshot on mac (cmd-shift-5) and saving it to the clipboard I try to "paste" to nvim/obsidian note but getting: "There is no image data in clipboard" message. The image is in the clipboard - can paste to other applications.
Config
Environment