Multi-frame GIFs to clipboard or photos
Is it possible to save a multi-frame GIF to the clipboard or to photos?
I am opening the GIF file in pythonista with
im = Image.open('test.GIF')
I see the clipboard.set_image() format parameter only has 'png' and 'jpeg' options.
Likewise when I use
the image does get saved to the camera roll but only the first frame, apparently.
@JonB I did try emailing and texting the file that gets saved to camera roll using photo.set_image(). Turns out it is a jpeg and it only has the initial frame.
One option: use console.quicklook to automatically display the image. Then , use the share button to share to email or imessage.
(might only work with the beta, quicklook and sharing worked differently in 1.5, but I am not sure)
Another option: serve up html, and open using safari, which should let you save to photos. The first open will be somewhat less intrusive.
If you open the gif in the editor, long press on it, and press save image using the native iOS dialog, you can save the whole gif. Save it the same way you would from safari if you saw it online.
Another solution is using an API like pyimgur to upload your GIF to the internet. Then, paste the link into your browser and save it from there.
Do you have the app Workflow by DeskConnect? Also, how many frames are in the GIF?
@Gerzer I do not have Workflow. Number of Frames can be anywhere between 4 and 12 or so.
@Webmaster4o Thanks for the tips. I can do your first one, but getting back to the editor involves closing the app -- so not quite ideal. Your second idea is interestings... I will look into that.
Then the solution I had in mind won't work. Oh, well. I'll keep thinking. :)
It would work if you'd be willing to put down some money for Workflow. It's a great app and is quite useful for Pythonista users. I'm not trying to pressure you into buying it, though. Do so only if you want to.
Here is a fully functional implementation of MFMailComposeView which lets you precompose an email, and attach a file. Any file type is allowed, although you will need to know the proper mime type name, such as image/gif, or application/zip for emailing zip files, etc. The user chooses to send or cancel from the ios mail composer.
The example main() shows also how this would work if launching from a ui-- you need to use
closebefore displaying the mail controller. you could edit the callback to display it again after dismissing the mail sheet.
@JonB Yes, this looks like an awesome solution. I see it uses the objc_util so I think that means I would need the beta, or else wait for the next release. But I think something like this is the long-term solution. Appreciate it!
Using objc_util, which I really don't understand well at all, and working off examples I've found here and there on this forum, I feel like I almost have it.... just trying to put an animated GIF onto the clipboard so it can be pasted into another app.
Method 1 below (commented out) works, but when the image is pasted it is unfortunately a .PNG.
Method 2 allows you to specify image type. However, this does not seem to work at all. Clipboard is empty.
# coding: utf-8 from objc_util import * UIPasteboard=ObjCClass('UIPasteboard') pb=UIPasteboard.generalPasteboard() #method 1: works but creates a .png: #imgdata = UIImage.imageWithContentsOfFile_('test.gif') #pb.setImage_(imgdata) # method 2: does not work. pasteboard is empty imgdata = NSData.dataWithContentsOfFile_('test.gif') pb.setData_forPasteboardType_(imgdata, ns('kUTTypeGIF'))
Method 2 should work if you use
'com.compuserve.gif'(the UTI for GIF images) instead of
'kUTTypeGIF'. The latter is the name of a constant/macro, it would get replaced by the preprocessor if you were writing actual Objective-C code.
I've tested this with an animated GIF, and was able to paste it in an email.
It works! Awesome, thanks!