OSX Applescript/Automator action to trim + untrim videos in iPhoto - macos

Can Applescript or Automator do specific repeatable steps within OS X apps, specifically iPhoto? If so, i'd love to see some examples!
I want to do the "fix" described in the link below on hundreds of video files in an iPhoto library: how-to-trim-and-share-video-in-iphoto-tutorial
In a nutshell, to get around a problem where iPhoto video thumbnails show up as black (and the built in "rebuild thumbnails" command fails) one can do the following steps to force iPhoto to regenerate a new "correct" (not black) thumbnail:
1) Open Video
2) Video Options (little gear icon) -> Trim
3) Trim left .1 second (this forces iPhoto to regen a thumbnail)
4) Video Options -> Reset Trim
These steps solve the problem but are very time consuming, so if there's a way to automate the steps above, i would be forever grateful to know how!

Related

Gimp Script-Fu: Delete a selection

I'm trying to write a script for Gimp that will crop an image, make a circular selection of what's left, invert the selection, and then delete the selection. I have the cropping, selection, and inversion part done, but the deleting is what's getting me.
(removed old code, see update)
That's the code I have. What's confusing me about the gimp-item-delete code is the item. I understand that I need to define my current selection as the item, but I'm not sure how to do this. If someone could explain how to do this, I would greatly appreciate it! Alternatively, if there's an easier way to do what I'm trying to do (but preferably still in a script), please let me know what you think. My knowledge of this coding is pretty limited, so simple explanations are appreciated.
UPDATE/EDIT:
Here's the (full) updated code:
; XML2 Conversation Portrait Preview Crop
(define (script-fu-xml2-convo-preview image layer)
(gimp-image-undo-group-start image)
(gimp-selection-none image)
(gimp-image-resize image 152 152 -280 -496)
(gimp-layer-resize-to-image-size layer)
(gimp-image-select-ellipse image 0 0 0 152 152)
(gimp-selection-invert image)
(gimp-displays-flush)
(gimp-drawable-edit-clear layer)
(gimp-selection-none image)
(gimp-image-undo-group-end image)
)
; populate script registration information
(script-fu-register
"script-fu-xml2-convo-preview"
"XML2 Conversation Portrait Preview Crop"
"Crops the preview window for XML2 conversation portraits."
"BaconWizard17"
"BaconWizard17"
"September 2021"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
)
; register the script within gimp menu
(script-fu-menu-register "script-fu-xml2-convo-preview" "<Image>/Marvel Mods/Skin Previews/XML2 PC")
So when I'm running this script, it appears to just crop it and doesn't delete the inverted circular selection. However, if I interact with the image in any way (click on it, duplicated it, copy/paste it, undo/redo), it will correct itself and show the properly cropped image with the deleted circular corners. When I first run the script, it also shows the incorrect image up at the top where you can pick which image you're working on, but after interacting with the image it will show the correct image. Here's an example:
The starting image that I create from the clipboard with Ctrl+Shift+V (after screenshotting it from the game using PrtScr):
Then, I run the script, which results in this:
At the top of the screen, the image shows up like this (which is the top left 152x152 pixels of the starting image:
How the image looks once I interact with it in any way (clicking on it, copy/pasting it, duplicating it, undoing/redoing the operation):
The thumbnail at the top of the screen after I interact with the image:
Maybe it's getting hung up on something during the operation? I'm not sure. I understand if this issue is unavoidable, but I would prefer to be able to just run the script and move on rather than having to interact with the image to get it to show up correctly. The image does have an alpha layer when it's pasted in.
gimp-item-delete is a memory/object management thing and is rarely used. What you are looking for is gimp-drawable-edit-clear.
Note that it should be done (together with your final gimp-selection-none) before gimp-image-undo-group-end if you want your whole script to be undone by a single Ctrl-Z.
Edit: It appears that your code works, it's just that the display isn't updated to show the result, which is exactly what gimp-display-flush is meant to do, so why is your code calling it before gimp-drawable-edit-clear? gimp-display-flush ought to be about the last thing done by your script.

Creating animated GIF files out of D3.js animations

I am creating D3.js animations, like this: Demo
Let's say I want to present my work here (or on a blog). About the best I can do is post a picture:
On the other hand, if I, let's say, use the Python library Matplotlib for data visualization, I could produce an animated GIF file, and post it here:
I would like to programatically obtain similar animated GIF files out of my D3.js animations. How can I do this?
NOTE: I started working on getting events from d3.transition(), but so far I didn't have any luck.
The solution uses a tool called LICEcap, a screen capture utility for Windows and Mac. Steps are following:
Download LICEcap and install it. Now, if you start this program, it will have a rather unusual shape, just a thin frame, and everything inside the frame will be transparent:
Go to the window with your D3.js animation and prepare everything so that you could start animation at some point. Let's say we want to record this example from d3js.org:
Now start LICEcap and position it over the area you want to have in your animated GIF file:
Make sure that you enter at least 20 FPS in the bottom left edit box, otherwise the recording will be low quality. Press record. A dialog will first appear, and you choose here whether you want your GIF file to be in an infinite loop, or just repeated once, or any number of times. Also an interesting option is to add some visual clues for mouse clicks. Choose also filename, and press Save.
Now you do whatever you have to do to trigger animations. I pressed buttons Grouped and Stacked several times. After I decided it's enough, I pressed Stop. The resulting file is:
That's it!

Copy and paste or drag and drop plots as PDF from R in OSX?

Is there any device or OSX software that allows for copy/paste as PDF, like in Mathematica?
I can copy plots as bitmaps from Quartz devices in the standard GUI and (at arbitrary resolution) in RStudio, but there a frequent occasions when I want vector graphics.
Edit:
I am aware of PDF exporting and devices, but am interested in a somewhat quicker workflow. The purpose here is for class handouts, where I mostly just want those printouts to come out without the obvious jaggies. It's not sensible, I know (only class notes after all), but it drives me crazy. I quite like the Copy As PDF feature from Mathematica for this reason. It works nicely for putting the same plot in the notes and in Keynote.
RStudio will do it (look at Export -> Save Plot as PDF as Arun says above). Alternately you can export something as an image but choose .svg as the file type.
You can do this in base R depending on your graphics device and other stuff external to R. If you type:
> capabilities(what = "cairo")
cairo
TRUE
Then you can probably export as PDF or svg outside of RStudio. See help("svg") for an explanation of the functions and arguments.
Edit:
If you want to copy directly from the x11 device to the clipboard you can do this from the Edit menu in R. I don't think you can drag directly from an x11 device to a non-x11 app (because the clipboards are different). But Edit -> Copy should work as expected and you can then paste w/ Command + V (on mac) into whatever app you like. You can test this out by running R (not RStudio) and plotting something trivial like plot(1:10, 1:10) then copying the output as described above into an app. It should save as a pdf file.
The quartz device allows copying to the clipboard and pasting into Preview.app with "New from Clipboard" results in a PDF file. So I guess I don't really understand what the problem is.

GUI for multiple OpenCV videos

I want to build a GUI for a OpenCV application. What I want to accomplish is show multiple videos in one Window and show a tracker in the same window.
Please help
First of all, if you're asking for help on the tracker, please consult the OpenCV documentation (cvNamedWindow and cvCreateTrackbar). As for having multiple videos in one window, it's relatively easy. All you need to do is create an image that can hold the frames for all of your videos. For example, if you have two videos # 320x240 each, create a frame that can hold a 640x240 frame. Call off to cvQueryFrame (two times -- one for each source). Copy the first result into the left half of the image, and the second result into the right half. Then call off to cvShowImage with the concatenated images and you're done! Hope that helps :)

what language/libraries an app that has a video preview window?

I want to make a simple assistant for putting together AviSynth scripts. This would be a windows desktop application that would have a "preview" screen of an avi movie, which would give you a timeline, play, fast-forward, rewind, advance and go back frame-by-frame. The program would need to know the frame number of the current frame in the player and its filename.
What language is best suited for this? I know PHP ( I understand that this is not a contender ) and am familiar with Java. My thought is that the biggest hurdle with this project will be finding a library for the video playing features. With a cursory glance, no Java video libraries jumped out at me. My next thought would be c++ for this.
The output of this program would be an AviSynth script, a plaintext file which looks like this:
AviSource("myAvi.avi")
Crop(0, 0, 320, 240)
Blur(0.1)
There are a few tool kits that can do tihs:
C#: DirectShow (DirectX)
Java: JMF
If you have Avisynth installed, the only thing you need for preview (If I understood, that's your need) is something that can decode uncompressed video. It would open like a normal file. I'm sure there are video players implemented fairly well in Java, but I don't know how much functionallity from them you need. Anyway parsing scripts is not easy - I recommend you not to try to if you don't need to.
EDIT: I'm sorry, I thought you needed a very specific app, but from what you seem to need, you don't need to code anything, use AVSP!
Please watch this video, it shows how straightforward it is. It has advanced functions such as auto-completion, (even from your own auto-loading scripts!) syntax coloring, macros, automtic importing, drag&drop (of a video, for instance - just drag it to the video and AVSP makes the loading) scrit preview with zoom and all stuff, you can use automatic or custom sliders (you can make a slider that re-writes a number on the script in real time, for instance for hue/luminosity/contrast/etc. that would be cumbersome to control via script), checkboxes & radio buttons (for boolean values, etc...), text fields that alter strings in real time, and basically anything you need... Please check it out.
Also, VirtualDubMod is OLD.
And yep, AVSP is free, both gratis and libre! =)

Resources