Multi-frame GIFs to clipboard or photos
-
Hello,
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
photos.save_image(im)
the image does get saved to the camera roll but only the first frame, apparently.
Thanks,
Mike
-
@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
close
before 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!