-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy the GIF directly to the clipboard #2
Comments
Dun. |
How? I am holding CMD before pressing enter and the gif is not copying to the pasteboard? |
Ah, I screwed it up. New release with the fix: https://github.com/kejadlen/giphy.alfredworkflow/releases/tag/v2.0.2 |
I saw you changed the filter variable check from {var:copy} to {var:giphy_copy}, that's what i was going to try to see if you had made a mistake. but even with that fix I am having trouble and cannot get it to work. the modifier key is working, because I substituted the script with a notification, but the gif isn't copying to pasteboard |
Ah, I was afraid of that. There should be a binary in the workflow called |
the binary didn't work but using the swift interpreter did
|
You can probably compile the Swift script yourself to make it work, but I don't know how to distribute it to work for everyone, so... ¯_(ツ)_/¯ |
Yeah, dunno. I didn't compile it I just changed it to run the script with the interpreter |
Maybe I'll switch it to that for now, thanks for the update. |
Re-opening to figure out a way to make this actually work. |
when I got it to work the script was only copying the image to the NSPasteBoard as PNG, (not animated GIF) so yeah |
@invious I saw that you forked the workflow - does paste.swift work? I couldn't get that to work. It would probably help if I knew how to copy an animated gif to the clipboard just in general... |
@kejadlen it used to work! some update must have broken my code. the date of those releases, the code was working. I remember looking far and wide for pasting gif to the keyboard, i can try to look again. Maybe there are some hints in my broken code. |
@kejadlen I think I fixed it! Takes the url as an argument.
|
@invious What OS and version of Swift are you using? This is what I'm trying, which should be pretty much the same as what you're doing, but it's not working for me: let pasteboard = NSPasteboard.general()
pasteboard.clearContents()
pasteboard.declareTypes([NSFilenamesPboardType], owner: nil)
let url = URL(fileURLWithPath: "/absolute/path/to/gif.gif")
pasteboard.writeObjects([url as NSPasteboardWriting]) When I paste this, I still get a still image. |
Xcode 8, Swift 3.0.1 I don't know but the code I pasted works. Here is my working workflow: https://cl.ly/2T2m1E0m3l0y |
Did it work for you? |
Gave it a shot, but it doesn't work for me. |
Works for me... just so people know, these are the steps I'm doing...
|
I still can't get this to work? |
Ditto - that only copies the link to the gif for me. |
Hello. I fixed the swift so that copying works. |
@aliparr- I just installed your new release, and holding the cmd modifier gives a GIF copied notification but when I paste into iMessage, it just pastes the url. God I swear I got my fork to work at one point. I distinctly remember joyfully pasting Gifs into imessage from alfred >_< |
Tracking some of the research I'm doing: Copying a GIF from Safari: let pb = NSPasteboard.general
let item = pb.pasteboardItems?.first
for type in item!.types {
print(type.rawValue)
}
I'm able to paste the animated GIF into TextEdit, but it doesn't seem to work for Slack/Chrome. |
Some other notes:
|
@invious - That's really weird to me. I have it working perfectly here. Would you mind running the alfred debugger on the script and seeing what it throws up? |
Swift 3.1
Oh and actually I was wrong about it copying the url, that was the previous thing on my clipboard, so I mistakenly thought it was the result of running the script with the CMD modifier, but nothing gets put on the clipboard despite the notification |
@aliparr- How are you testing that copying the animated gif works? |
@kejadlen - I can paste it where I want. iMessage, whatsapp, anywhere. It's working 100% for me. Can you try updating Swift and giving my version a go? |
@aliparr- Interesting... can you check to see what the following returns when you do
|
I get this sort of thing: |
Did some further digging into this today. Got this to work: import Cocoa
let path = CommandLine.arguments[1]
let url = URL(fileURLWithPath: path).absoluteURL as NSURL
let pb = NSPasteboard.general
pb.declareTypes([NSPasteboard.PasteboardType.fileContents], owner: nil)
pb.writeObjects([url]) |
Okay, new release that hopefully implements direct copying of GIFs: https://github.com/kejadlen/giphy.alfredworkflow/releases/tag/v3.1.1 There is still some odd behavior that I haven't been able to nail down - it seemed like it sometimes only worked after I ran the script from the commandline, so that's something to look out for. |
This failed for me because
|
One thing you can try is compiling |
Fixed it on my end. Here are the issues I found.
Works. |
@florinme do you have a working fork? I couldn't quite follow your instructions. I downloaded, chmoded, and added the imgpbcopy file to my path but you lost me at step 2 |
So out of curiousity, what are y’all pasting animated GIFs into? |
Apple Messages. Often times I don't have the text field highlighted, and so returning the gif directly didn't work for me, which is why I'd rather control when the output happens. |
ditto |
I tried what you did but could not get it to work. Out of curiosity the imgpbcopy does work as I ran this via terminal with a Giphy link; however, I noticed that how the Giphy url is copied through this workflow it doesn't work via terminal. For example, this is the url for 'hello world' https://media1.giphy.com/media/lcs5BL0NIM4WMv61a9/giphy.gif?cid=e1bb72ff1e937d0c558ace37ce09ebd2dd622bb6557907b3&rid=giphy.gif. I can't have the gif copy to clipboard via the imgpbcopy unless I remove everything after the '?'. |
It appears to be working for me with what's currently in the workflow ( |
Did you change the imgpbcopy? |
@mar005 I have the relevant portion of |
Do we need the new code from December in order to get copy to work? I'm having trouble actually copying the image myself, pressing enter just shows the qlmanage preview. Edit: Ah, pressing Cmd + Enter successfully copies the gif. Thanks! |
I came across this thread while trying to support this feature in my own app. I finally managed it using this code: perhaps you'll be able to benefit?
|
@aaronvegh Are you copying remote gifs from a URL or local files in the bundle? Do you have a more full code sample? |
In my application's case, I'm copying URLs, but this handles both local and remote URLs. Not sure if this will be helpful for you, but here are two methods from my app that handle copying images that handle the image file in one instance, and the URL in another: @IBAction func copyOriginalURL(sender: NSMenuItem) {
guard let gif = gif,
let originalURL = gif.url else { return }
// put it on the clipboard
let pasteboardItem = NSPasteboardItem()
pasteboardItem.setString(originalURL, forType: .string)
let pasteboard = NSPasteboard.general
pasteboard.clearContents()
pasteboard.writeObjects([pasteboardItem])
}
@IBAction func copyOriginalImage(sender: NSMenuItem) {
guard let localPath = localPath else { return }
let pb = NSPasteboard.general
do {
let fileType = try NSWorkspace.shared.type(ofFile: localPath.path)
let pasteboardType = NSPasteboard.PasteboardType.init(fileType)
pb.declareTypes([pasteboardType], owner: nil)
pb.clearContents()
pb.writeObjects([localPath as NSURL])
} catch {
return
}
} |
@aaronvegh This copies the URL to the clipboard, but not the .gif file itself, right? I'm attempting to copy the .gif from my app and paste directly into another app, i.e. Messages. |
I find this works to do exactly what you're after. For the "actual file", you're really wanting to put the URL in the pasteboard. In a different part of my app where I have to return an object that conforms to |
@aaronvegh Interesting. When I do this and go to paste in Messages, it just pastes the remote URL of the file. |
It seems as though what we copy is just a JPEG file, the gif is running fine on my mac when I paste it into iMessage, but when i switch over to my phone's iMessage, it reads as a JPEG picture and doesn't animate. Huh??? |
FWIW: the applications where I need to be able to paste a gif works if I had a gif on my filesystem and I copied the file through finder via the context menu. Since that works, I tried updating the script in the workflow to just set the clipboard to the tmp file (instead of reading it in)
And that works for me. YMMV, I didn't test iMessages or other common applications people might use for messaging |
I'm having this issue too (@kejadlen I got it to stop crashing! I didn't have python 2 installed 🤦). It only copies a static image. |
No description provided.
The text was updated successfully, but these errors were encountered: