#target photoshop app.bringToFront() function workIt() { var overlapWidth = UnitValue(wnd.panel1.formatX.text, "px"); var overlapHeight = UnitValue(wnd.panel1.formatY.text, "px"); var overlapPercent = (100 - wnd.panel1.overlapChooser.value)/100; if(wnd.panel1.resampleMethodChooser.selection.text == "Bicubic") var resampleMethod = ResampleMethod.BICUBIC; if(wnd.panel1.resampleMethodChooser.selection.text == "Bicubic Sharper") var resampleMethod = ResampleMethod.BICUBICSHARPER; if(wnd.panel1.resampleMethodChooser.selection.text == "Bicubic Smoother") var resampleMethod = ResampleMethod.BICUBICSMOOTHER; if(overlapWidth != 0 && overlapHeight != 0) { // store units var startRulerUnits = app.preferences.rulerUnits; var startTypeUnits = app.preferences.typeUnits; var startDisplayDialogs = app.displayDialogs; // modify units to pixels app.preferences.rulerUnits = Units.PIXELS; app.preferences.typeUnits = TypeUnits.PIXELS; app.displayDialogs = DialogModes.NO; var myDoc = app.activeDocument; selectAllLayers(); makeSelectedLayersSmartObject(myDoc.name); // if image is not in portrait mode => swap overlapWidth and overlapHeight if(myDoc.width >= myDoc.height) { var tmp = overlapWidth; overlapWidth = overlapHeight; overlapHeight = tmp; } var myNewImageWidth = overlapWidth * overlapPercent; var myNewImageHeight = overlapHeight * overlapPercent; if(myDoc.width != myNewImageWidth || myDoc.height < myNewImageHeight) { if((myNewImageWidth - myDoc.width) < (myNewImageHeight - myDoc.height)) { myDoc.resizeImage(myNewImageWidth, undefined, 400, resampleMethod); } else { myDoc.resizeImage(undefined, myNewImageHeight, 400, resampleMethod); } } myDoc.resizeCanvas(overlapWidth, overlapHeight); var myLayer = myDoc.artLayers.add(); var colorGray = new SolidColor(); colorGray.rgb.hexValue = "a1a1a1"; myDoc.selection.selectAll(); myDoc.selection.fill (colorGray); myDoc.selection.deselect(); myLayer.isBackgroundLayer = true; zoomToFit(); // resets units app.preferences.rulerUnits = startRulerUnits; app.preferences.typeUnits = startTypeUnits; app.displayDialogs = startDisplayDialogs; } } function selectAllLayers() { var layerNum = app.activeDocument.layers.length; for(var i = 0; i < layerNum; i++) { var layer = app.activeDocument.layers[i]; selectLayer(layer.name, (i>0)); } } function selectLayer(layerName, addToSelection) { var id84 = charIDToTypeID( "slct" ); var desc18 = new ActionDescriptor(); var id85 = charIDToTypeID( "null" ); var ref13 = new ActionReference(); var id86 = charIDToTypeID( "Lyr " ); ref13.putName( id86, layerName ); desc18.putReference( id85, ref13 ); if(addToSelection) { var id87 = stringIDToTypeID( "selectionModifier" ); var id88 = stringIDToTypeID( "selectionModifierType" ); var id89 = stringIDToTypeID( "addToSelection" ); desc18.putEnumerated( id87, id88, id89 ); } var id90 = charIDToTypeID( "MkVs" ); desc18.putBoolean( id90, false ); executeAction( id84, desc18, DialogModes.NO ); } function makeSelectedLayersSmartObject(layerName) { // merge to SmartObject var id34 = stringIDToTypeID( "newPlacedLayer" ); executeAction( id34, undefined, DialogModes.NO ); // rename SmartObject to layerName var id35 = charIDToTypeID( "setd" ); var desc7 = new ActionDescriptor(); var id36 = charIDToTypeID( "null" ); var ref5 = new ActionReference(); var id37 = charIDToTypeID( "Lyr " ); var id38 = charIDToTypeID( "Ordn" ); var id39 = charIDToTypeID( "Trgt" ); ref5.putEnumerated( id37, id38, id39 ); desc7.putReference( id36, ref5 ); var id40 = charIDToTypeID( "T " ); var desc8 = new ActionDescriptor(); var id41 = charIDToTypeID( "Nm " ); desc8.putString( id41, layerName ); var id42 = charIDToTypeID( "Lyr " ); desc7.putObject( id40, id42, desc8 ); executeAction( id35, desc7, DialogModes.NO ); } function zoomToFit() { var id29 = charIDToTypeID( "slct" ); var desc7 = new ActionDescriptor(); var id30 = charIDToTypeID( "null" ); var ref2 = new ActionReference(); var id31 = charIDToTypeID( "Mn " ); var id32 = charIDToTypeID( "MnIt" ); var id33 = charIDToTypeID( "FtOn" ); ref2.putEnumerated( id31, id32, id33 ); desc7.putReference( id30, ref2 ); executeAction( id29, desc7, DialogModes.NO ); } /* **************************************************************************************************************** */ var printFormats = new Array(); printFormats.push("fcprints print formats"); printFormats.push("-"); printFormats.push("9x13cm (1339*2000px)"); printFormats.push("-"); printFormats.push("10x13cm (1606*2142px)"); printFormats.push("10x15cm (1606*2394px)"); printFormats.push("10x20cm (1606*3150px)"); printFormats.push("-"); printFormats.push("13x13cm (2000*2000px)"); printFormats.push("13x17cm (2000*2661px)"); printFormats.push("13x18cm (2000*2803px)"); printFormats.push("13x19,05cm (2000*3000px)"); printFormats.push("-"); printFormats.push("15x20cm (2394*3197px)"); printFormats.push("15x21cm (2502*3307px)"); printFormats.push("-"); printFormats.push("18x24cm (2803*3780px)"); printFormats.push("-"); printFormats.push("20x20cm (3197*3197px)"); printFormats.push("20x25cm (3197*4000px)"); printFormats.push("20x28cm (3197*4409px)"); printFormats.push("20x30cm (3197*4803px)"); printFormats.push("-"); printFormats.push("21x21cm (3307*3307px)"); printFormats.push("21x28cm (3307*4409px)"); printFormats.push("21x29,7cm A4 (3307*4677px)"); printFormats.push("-"); printFormats.push("24x30cm (3780*4803px)"); printFormats.push("-"); printFormats.push("25x25cm (4000*4000px)"); printFormats.push("-"); printFormats.push("30x30cm (4803*4803px)"); printFormats.push("30x40cm (4803*6331px)"); printFormats.push("30x45cm (4803*7118px)"); var resampleMethods = new Array(); resampleMethods.push("Bicubic"); resampleMethods.push("Bicubic Sharper"); resampleMethods.push("Bicubic Smoother"); /* **************************************************************************************************************** */ var wnd = new Window('dialog', 'fotocommunity Prints: Print-Assistant'); // Bereich: Format wnd.panel1 = wnd.add('panel', [10, 10, 390, 150], 'Parameters'); wnd.panel1.add('statictext', [10, 22, 110, 40], "Format"); wnd.panel1.formatChooser = wnd.panel1.add('dropdownlist', [120, 20, 335, 40], printFormats); wnd.panel1.formatX = wnd.panel1.add('edittext', [120, 45, 180, 65], ''); wnd.panel1.add('statictext', [185, 47, 192, 65], ' x '); wnd.panel1.formatY = wnd.panel1.add('edittext', [197, 45, 257, 65], ''); wnd.panel1.add('statictext', [263, 47, 285, 65], 'px'); wnd.panel1.formatChooser.selection = 0; wnd.panel1.formatChooser.onChange = function() { var format = wnd.panel1.formatChooser.selection.text; if(format != null) { format = format.split("(")[1]; format = format.split("px)")[0]; format = format.split("*"); wnd.panel1.formatX.text = format[0]; wnd.panel1.formatY.text = format[1]; } } wnd.panel1.add('statictext', [10, 75, 110, 95], "Overlap"); wnd.panel1.overlapChooser = wnd.panel1.add('slider', [120, 75, 335, 95], 2, 0, 100); wnd.panel1.overlapChooserValue = wnd.panel1.add('statictext', [345, 75, 485, 95], wnd.panel1.overlapChooser.value + "%"); wnd.panel1.overlapChooser.onChanging = function() { wnd.panel1.overlapChooserValue.text = wnd.panel1.overlapChooser.value + "%"; }; wnd.panel1.add('statictext', [10, 107, 110, 125], "Resample-Method"); wnd.panel1.resampleMethodChooser = wnd.panel1.add('dropdownlist', [120, 105, 335, 125], resampleMethods); wnd.panel1.resampleMethodChooser.selection = 0; // Bereich: Ausführen wnd.panel2 = wnd.add('panel', [10, 160, 390, 220], 'Execute'); wnd.panel2.okButton = wnd.panel2.add('button', [20, 15, 70, 40], 'OK', {name: 'ok'}); wnd.panel2.abortButton = wnd.panel2.add('button', [80, 15, 150, 40], 'Cancel', {name: 'cancel'}); // Anzeige if(wnd.show() == 1) workIt();