here's efficient code for dissolves

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

filmmaker

here's efficient code for dissolves

Post by filmmaker »

i run through thousand of files at a time which are 40 to 145 MB each so this is power/reduced code, there is no error checking, nothing pretty or fancy, just run fast and hard.

what it does is open two separate files, create a third scratch file,

don't use dup, or you'll run into naming convention problems and probably run out of ram and start paging.

vary the opacity or blend to suit.

if you create an initial big stack of 90+frames, you'll probably bring your computer to a crawl.

this code could easily be threaded, if i could find the PS threading calls, each opacity could be called separately instead of one at a time but i can't get PS to thread out the loops.



// fortran conventions always declare variable and initialize before using
var w=5782;
var h=3946;
var dpi=72;
var sec=2;
var fps=1;
var frames=fps*sec;
var fmask='*.psd';
var i=0;
var output_dir="D:/ps_scripts/wipe";
var fname=output_dir+"/frame_";
var files=new Array("D:/ps_scripts/ba01127.psd","D:/ps_scripts/ba01137.psd");
//345678901234567890123456789012345678901234567890123456789012345678901234567890//
var newdoc1 = app.documents.add(h,w, dpi,"TEMP_DOC_1", NewDocumentMode.GRAYSCALE,DocumentFill.TRANSPARENT);
var f1=files[0];
var fin_1=new File(f1);
var fdoc_1=app.open(fin_1);
fdoc_1.activeLayer.duplicate( newdoc1 );
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument.mergeVisibleLayers();
app.activeDocument.activeLayer.name="frame_0";

var newdoc2 = app.documents.add(h,w, dpi,"TEMP_DOC_2", NewDocumentMode.GRAYSCALE,DocumentFill.TRANSPARENT);
var f2=files[1];
var fin_2=new File(f2);
var fdoc_2=app.open(fin_2);
fdoc_2.activeLayer.duplicate( newdoc2 );
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument.mergeVisibleLayers();
app.activeDocument.activeLayer.name="frame_0";
//change opacity and merge
for(i=1;i<=2; i++){
var newdoc3 = app.documents.add(h,w, dpi,"TEMP_DOC_3", NewDocumentMode.GRAYSCALE,DocumentFill.TRANSPARENT);
app.activeDocument.activeLayer.name="frame_0";
app.activeDocument =newdoc1;
newdoc1.activeLayer.duplicate(newdoc3 );
app.activeDocument =newdoc3;
app.activeDocument.activeLayer.name="frame_0";
app.activeDocument.layers[0].opacity = 50-i*15;
app.activeDocument =newdoc2;
newdoc2.activeLayer.duplicate(newdoc3 );
app.activeDocument =newdoc3;
app.activeDocument.activeLayer.name="frame_1";
app.activeDocument.layers[0].opacity = 50+i*5;
app.activeDocument.mergeVisibleLayers();
//
var frame_doc=new File(fname+i);
var frame_doc = new Folder ( frame_doc );
app.activeDocument.saveAs( frame_doc, psdSaveOptions, true, Extension.LOWERCASE);
app.activeDocument.saveAs( frame_doc, tiffSaveOptions, true, Extension.LOWERCASE);
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES );
};