Hello,
i want to employ a script to create images of dynamic width for me. The whole process shall base on different sized sets of images, which contain a left-image, a right-image and a center-image. The desired width for the different cases shall be reached by duplicating the center-image between the two outer images and placing those images next to each other until the image extends to desired width.
The layers importet into Photoshop shall be importet as smart-layers (which i already solved).
Has anyone done something similar already and could give me some useful hints on that issue ?
I have come up to this until now:
#target Photoshop // =========================== Opens a new document and asks for dimensions ============================ var myLayerset = File.openDialog ("Select the set of images you want to use!", "*.png",true) var myName = prompt("How do you want to call the document?"); // askes for document name var width = prompt("Please insert width for the output here!", ""); // askes for desired width var height = prompt("Please insert height for the output here!", ""); //askes for desired height var docName = myName +".psd" var idMk = charIDToTypeID( "Mk " ); var desc3 = new ActionDescriptor(); var idNw = charIDToTypeID( "Nw " ); var desc4 = new ActionDescriptor(); var idNm = charIDToTypeID( "Nm " ); desc4.putString( idNm, """Wunschname""" ); var idMd = charIDToTypeID( "Md " ); var idRGBM = charIDToTypeID( "RGBM" ); desc4.putClass( idMd, idRGBM ); var idWdth = charIDToTypeID( "Wdth" ); var idRlt = charIDToTypeID( "#Rlt" ); desc4.putUnitDouble( idWdth, idRlt, width ); var idHght = charIDToTypeID( "Hght" ); var idRlt = charIDToTypeID( "#Rlt" ); desc4.putUnitDouble( idHght, idRlt, height ); var idRslt = charIDToTypeID( "Rslt" ); var idRsl = charIDToTypeID( "#Rsl" ); desc4.putUnitDouble( idRslt, idRsl, 72.000000 ); var idpixelScaleFactor = stringIDToTypeID( "pixelScaleFactor" ); desc4.putDouble( idpixelScaleFactor, 1.000000 ); var idFl = charIDToTypeID( "Fl " ); var idFl = charIDToTypeID( "Fl " ); var idTrns = charIDToTypeID( "Trns" ); desc4.putEnumerated( idFl, idFl, idTrns ); var idDpth = charIDToTypeID( "Dpth" ); desc4.putInteger( idDpth, 8 ); var idprofile = stringIDToTypeID( "profile" ); desc4.putString( idprofile, """sRGB IEC61966-2.1""" ); var idDcmn = charIDToTypeID( "Dcmn" ); desc3.putObject( idNw, idDcmn, desc4 ); executeAction( idMk, desc3, DialogModes.NO ); //==============================================save document================================================ var idsave = charIDToTypeID( "save" ); var desc4 = new ActionDescriptor(); var idAs = charIDToTypeID( "As " ); var desc5 = new ActionDescriptor(); var idmaximizeCompatibility = stringIDToTypeID( "maximizeCompatibility" ); desc5.putBoolean( idmaximizeCompatibility, true ); var idPhtthree = charIDToTypeID( "Pht3" ); desc4.putObject( idAs, idPhtthree, desc5 ); var idIn = charIDToTypeID( "In " ); desc4.putPath( idIn, new File( "C:\\Users\\ target folder goes here" + docName ) ); var idDocI = charIDToTypeID( "DocI" ); desc4.putInteger( idDocI, 308 ); var idsaveStage = stringIDToTypeID( "saveStage" ); var idsaveStageType = stringIDToTypeID( "saveStageType" ); var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" ); desc4.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded ); executeAction( idsave, desc4, DialogModes.NO ); //======================================================================================================== for (var i = 0; i < myLayerset.length; i++) { if (myLayerset[i] instanceof File && myLayerset[i].hidden == false) { // ======================================================= opens selected images as smart objects==================== var idOpn = charIDToTypeID( "Opn " ); var desc1 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); desc1.putPath( idnull, myLayerset[i]); var idsmartObject = stringIDToTypeID( "smartObject" ); desc1.putBoolean( idsmartObject, true ); executeAction( idOpn, desc1, DialogModes.NO ); //===================================duplicates opened layer into created document======================================== var idDplc = charIDToTypeID( "Dplc" ); var desc144 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref135 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref135.putEnumerated( idLyr, idOrdn, idTrgt ); desc144.putReference( idnull, ref135 ); var idT = charIDToTypeID( "T " ); var ref136 = new ActionReference(); var idDcmn = charIDToTypeID( "Dcmn" ); ref136.putName( idDcmn, docName); desc144.putReference( idT, ref136 ); var idVrsn = charIDToTypeID( "Vrsn" ); desc144.putInteger( idVrsn, 5 ); executeAction( idDplc, desc144, DialogModes.NO ); // ======================================================= close tab without saving ========== var idCls = charIDToTypeID( "Cls " ); var desc156 = new ActionDescriptor(); var idSvng = charIDToTypeID( "Svng" ); var idYsN = charIDToTypeID( "YsN " ); var idN = charIDToTypeID( "N " ); desc156.putEnumerated( idSvng, idYsN, idN ); executeAction( idCls, desc156, DialogModes.NO ); } }