Last active
February 27, 2018 00:22
-
-
Save n1ckfg/c3c6f109f2665dd9e372da8370bc9538 to your computer and use it in GitHub Desktop.
After Effects batch example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function uprez() { | |
| app.beginUndoGroup("Uprez"); | |
| var theComps = getSelectedComps(); | |
| if (theComps.length < 1) { | |
| alert("No comps selected."); | |
| } else { | |
| for (var i=0; i<theComps.length; i++) { | |
| theComp = theComps[i]; | |
| theComp.width = 2160; | |
| theComp.height = 2160; | |
| var theLayer = theComp.layers[1]; | |
| theLayer.property("Transform").property("Position").setValue([theComp.width/2.0, theComp.height/2.0]); | |
| var fx_Upscale = theLayer.property("Effects").addProperty("Detail-preserving Upscale"); | |
| fx_Upscale.property("Scale").setValue((theComp.width / getDim(theLayer)[0]) * 100.0); | |
| var fx_Levels = theLayer.property("Effects").addProperty("Levels"); | |
| fx_Levels.property("Input Black").setValue(16.0/255.0); | |
| fx_Levels.property("Input White").setValue(235.0/255.0); | |
| // precompose so upscale doesn't cause problems with high pass preset | |
| thePrecomp = theComp.layers.precompose([theLayer.index], "Precomp_" + theLayer.name, true); | |
| var thePrecompLayer1 = thePrecomp.layers[1].duplicate(); | |
| thePrecompLayer1.blendingMode = BlendingMode.COLOR; | |
| thePrecompLayer1.property("Effects").addProperty("Gaussian Blur").property("Blurriness").setValue(50.0); | |
| var theLayer1 = theComp.layers[1]; | |
| var theLayer2 = theLayer1.duplicate(); | |
| theLayer1.blendingMode = BlendingMode.OVERLAY; | |
| theLayer1.property("Opacity").setValue("50.0"); | |
| theLayer1.applyPreset(getPreset("HighPass.ffx", true)); | |
| theLayer1.property("Effects").property("Monochrome On").property("Checkbox").setValue(0); | |
| theLayer1.property("Effects").property("Soften On").property("Checkbox").setValue(0); | |
| theLayer1.moveBefore(theLayer2); | |
| var solid = theComp.layers.addSolid([1.0, 1.0, 1.0], "Adjustment Layer 1", theComp.width, theComp.height, 1); | |
| solid.adjustmentLayer = true; | |
| solid.property("Effects").addProperty("Sharpen").property("Sharpen Amount").setValue(175.0); | |
| } | |
| } | |
| app.endUndoGroup(); | |
| } | |
| function getDim(layer) { | |
| //var time = app.project.activeItem.time; | |
| var x = layer.sourceRectAtTime(t=0, includeExtents=false).width; | |
| var y = layer.sourceRectAtTime(t=0, includeExtents=false).height; | |
| return [ x, y ]; | |
| } | |
| function getSelectedComps() { | |
| var returns = []; | |
| for (var i=1; i<app.project.items.length+1; i++) { | |
| var item = app.project.items[i]; | |
| if (item.selected==true && item instanceof CompItem) { | |
| returns.push(item); | |
| } | |
| } | |
| return returns; | |
| } | |
| function getPreset(filePath, local) { | |
| var presetPath = filePath; | |
| if (local==true) presetPath = new Folder((new File($.fileName)).path + "/" + presetPath); | |
| return File(presetPath); | |
| } | |
| function main() { | |
| uprez(); | |
| } | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment