Powered By Blogger

script buat pas foto

#target photoshop
// in case we double clicked the file
// Wempi erstudio
// http://wempi.nokspi.com
app.bringToFront();

main();

function main()
{
    if ( app.documents.length <= 0 ) {
        alert('You must have a document open!');
        return;
    }
    var id=new Object();
    id.s23=true;
    id.s34=true;
    id.s46=true;
    id.s55=false;
    id.s66=false;
    id.fsz=3.0;
    id.bsz=2.0;
    if (dodlg(id))
    {
        var doc=app.activeDocument;
        var oldU=app.preferences.rulerUnits;
        app.preferences.rulerUnits=Units.CM;
        doc.selection.selectAll();
        doc.selection.copy(doc.layers.length>1);
        doc.selection.deselect();
        if (id.s23) {
            NW=(20-id.bsz)/10;
            NH=(27-id.bsz)/10;
            nd=app.documents.add(NW,NH,400,"2x3",NewDocumentMode.RGB,DocumentFill.WHITE,1.0);
            nd.paste();
            L=nd.activeLayer;
            W=(NW/L.bounds[2])*100;
            L.resize(W,W,AnchorPosition.TOPLEFT);
            nd.flatten();
            nd.resizeCanvas(NW+id.fsz/10,NH+id.fsz/10);
            nd.selection.selectAll();
            app.preferences.rulerUnits=Units.PIXELS;
            nd.selection.selectBorder(1);
            app.preferences.rulerUnits=Units.CM;
             fillColor = new SolidColor();
              fillColor.rgb.red  = 0;
            fillColor.rgb.green = 0;
            fillColor.rgb.blue = 0;
            nd.selection.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
            fillColor = null;
            nd.selection.deselect();
        }
        if (id.s34) {
            NW=(30-id.bsz)/10;
            NH=(40-id.bsz)/10;
            nd=app.documents.add(NW,NH,400,"3x4",NewDocumentMode.RGB,DocumentFill.WHITE,1.0);
            nd.paste();
            L=nd.activeLayer;
            W=(NW/L.bounds[2])*100;
            L.resize(W,W,AnchorPosition.TOPLEFT);
            nd.flatten();
            nd.resizeCanvas(NW+id.fsz/10,NH+id.fsz/10);
            nd.selection.selectAll();
            app.preferences.rulerUnits=Units.PIXELS;
            nd.selection.selectBorder(1);
            app.preferences.rulerUnits=Units.CM;
             fillColor = new SolidColor();
              fillColor.rgb.red  = 0;
            fillColor.rgb.green = 0;
            fillColor.rgb.blue = 0;
            nd.selection.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
            fillColor = null;
            nd.selection.deselect();
        }
        if (id.s46) {
            NW=(40-id.bsz)/10;
            NH=(60-id.bsz)/10;
            nd=app.documents.add(NW,NH,400,"4x6",NewDocumentMode.RGB,DocumentFill.WHITE,1.0);
            nd.paste();
            L=nd.activeLayer;
            W=(NW/L.bounds[2])*100;
            L.resize(W,W,AnchorPosition.TOPLEFT);
            L.resize(105,105);
            nd.flatten();
            nd.resizeCanvas(NW+id.fsz/10,NH+id.fsz/10);
            nd.selection.selectAll();
            app.preferences.rulerUnits=Units.PIXELS;
            nd.selection.selectBorder(1);
            app.preferences.rulerUnits=Units.CM;
             fillColor = new SolidColor();
              fillColor.rgb.red  = 0;
            fillColor.rgb.green = 0;
            fillColor.rgb.blue = 0;
            nd.selection.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
            fillColor = null;
            nd.selection.deselect();
        }
        if (id.s55) {
            NW=(50-id.bsz)/10;
            NH=(50-id.bsz)/10;
            nd=app.documents.add(NW,NH,400,"5x5",NewDocumentMode.RGB,DocumentFill.WHITE,1.0);
            nd.paste();
            L=nd.activeLayer;
            W=(NW/L.bounds[2])*100;
            L.resize(W,W,AnchorPosition.TOPLEFT);
            nd.flatten();
            nd.resizeCanvas(NW+id.fsz/10,NH+id.fsz/10);
            nd.selection.selectAll();
            app.preferences.rulerUnits=Units.PIXELS;
            nd.selection.selectBorder(1);
            app.preferences.rulerUnits=Units.CM;
             fillColor = new SolidColor();
              fillColor.rgb.red  = 0;
            fillColor.rgb.green = 0;
            fillColor.rgb.blue = 0;
            nd.selection.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
            fillColor = null;
            nd.selection.deselect();
        }
        if (id.s66) {
            NW=(60-id.bsz)/10;
            NH=(60-id.bsz)/10;
            nd=app.documents.add(NW,NH,400,"6x6",NewDocumentMode.RGB,DocumentFill.WHITE,1.0);
            nd.paste();
            L=nd.activeLayer;
            W=(NW/L.bounds[2])*100;
            L.resize(W,W,AnchorPosition.TOPLEFT);
            nd.flatten();
            nd.resizeCanvas(NW+id.fsz/10,NH+id.fsz/10);
            nd.selection.selectAll();
            app.preferences.rulerUnits=Units.PIXELS;
            nd.selection.selectBorder(1);
            app.preferences.rulerUnits=Units.CM;
             fillColor = new SolidColor();
              fillColor.rgb.red  = 0;
            fillColor.rgb.green = 0;
            fillColor.rgb.blue = 0;
            nd.selection.fill( fillColor, ColorBlendMode.NORMAL, 100, false );
            fillColor = null;
            nd.selection.deselect();
        }
        app.preferences.rulerUnits=oldU;
    }
}

function dodlg(id)
{
    dlg=new Window("dialog","Buat Pas Poto");
    dlg.orientation='column';
    dlg.alignChildren='left';
    dlg.grpsize=dlg.add('group');
    dlg.grpsize.orientation='row';
    dlg.grpsize.alignChildren='fill';
    dlg.pnlsize=dlg.grpsize.add('panel',undefined,'Size');
    dlg.pnlsize.aligment='fill';
    dlg.pnlsize.orientation='row';
    dlg.cb23=dlg.pnlsize.add('checkbox',undefined,'2x3');
    dlg.cb34=dlg.pnlsize.add('checkbox',undefined,'3x4');
    dlg.cb46=dlg.pnlsize.add('checkbox',undefined,'4x6');
    dlg.cb55=dlg.pnlsize.add('checkbox',undefined,'5x5');
    dlg.cb66=dlg.pnlsize.add('checkbox',undefined,'6x6');
    dlg.cb23.value=id.s23;
    dlg.cb34.value=id.s34;
    dlg.cb46.value=id.s46;
    dlg.cb55.value=id.s55;
    dlg.cb66.value=id.s66;
    dlg.grpm=dlg.add('group');
    dlg.grpm.alignChildren='left';
    dlg.grpm.add('statictext',undefined,'Frame size');
    dlg.efsz=dlg.grpm.add('edittext',[0,0,40,18]);
    dlg.grpm.add('statictext',undefined,'Photo border');
    dlg.pbsz=dlg.grpm.add('edittext',[0,0,40,18]);
    dlg.efsz.text=id.fsz;
    dlg.pbsz.text=id.bsz;
    dlg.grpbtn=dlg.add('group');
    dlg.grpbtn.orientation='row';
    dlg.grpbtn.alignChildren='right';
    dlg.btnok=dlg.grpbtn.add("button",undefined,"Ok");
    dlg.btnok.onClick=function(){dlg.close(true)};
    dlg.btncancel=dlg.grpbtn.add('button',undefined,'Cancel');
    dlg.btncancel.onClick=function(){dlg.close(false)};
    dlg.center();
    var r=dlg.show();
    if (r==true)
    {
        id.s23=dlg.cb23.value;
        id.s34=dlg.cb34.value;
        id.s46=dlg.cb46.value;
        id.s55=dlg.cb55.value;
        id.s66=dlg.cb66.value;
        id.fsz=dlg.efsz.text;
        id.bsz=dlg.pbsz.text;
    }
    return r;
}