Scaling of text bound in a photoshop script
Hello
I am train across the bounding box of the text with the text inside.
I want to get the same effect, select the text box by double clicking on the text-> press-> cntrl then resize the frame enclosing the mouse
Here is my code to generate the text.
CRS is an object with properties of height, width, scaleX, scleY. I want to apply the scaling of the text.
function addText (crs)
{
If (documents.length > 0)
{
var originalDialogMode = app.displayDialogs;
app.displayDialogs = DialogModes.ERROR;
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
Try
{
var docRef = activeDocument;
Now create a layer of text on the front
var myLayerRef = docRef.artLayers.add ();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = 'Text Description';
var myTextRef = myLayerRef.textItem;
myTextRef.contents = crs.lableName;
Set the text to be in the Middle
myTextRef.position = new Array (crs.xPos, crs.yPos);
myTextRef.size = 20;
var internalFontName = getInternalFontName (crs.fontFamily, crs.fontType);
If (internalFontName! = null)
myTextRef.font = internalFontName;
var R = hexToR("#"+crs.fontColor);
var G = hexToG("#"+crs.fontColor);
var B = hexToB("#"+crs.fontColor);
Alert (crs.fontColor + "" + R + "" + G + "" + B);
function hexToR (h) {return parseInt (((h) cutHex) .substring (0.2), 16)}
function hexToG (h) {return parseInt (((h) cutHex) .substring (2,4), 16)}
function hexToB (h) {return parseInt (((h) cutHex) .substring (4,6), 16)}
function cutHex (h) {return (h.charAt (0) == "#")? h.substring (1.7): h}
If (IsNaN (R) == false & & isNaN (G) == false & & isNaN (B) == false)
{
textColor = new SolidColor();
textColor.rgb.red = R;
textColor.rgb.green = G;
textColor.rgb.blue = B;
myTextRef.color = textColor;
}
If (crs.isFontUnderline is "true")
myTextRef.underline = UnderlineType.UNDERLINELEFT;
If (crs.isStrikeThru is "true")
myTextRef.strikeThru = StrikeThruType.STRIKEHEIGHT;
If (crs.alignLeft is "true")
myTextRef.justification = Justification.LEFT;
Else if (crs.alignCenter == "true")
myTextRef.justification = Justification.CENTER;
Else if (crs.alignRight == "true")
myTextRef.justification = Justification.RIGHT;
}
catch (e)
{
An error has occurred. Restore units of the rule, and then spread the error return
to the user
Alert ("error");
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
throw e;
}
Everything went well. Restore units of the rule
preferences.rulerUnits = originalRulerUnits;
app.displayDialogs = originalDialogMode;
}
on the other
{
Alert ("you must have a document open to add the file name! ');
}
var idsetd = charIDToTypeID ("setd");
var desc153 = new ActionDescriptor();
var idnull = charIDToTypeID ("null");
var ref62 = new ActionReference();
var idPrpr = charIDToTypeID ("Rprp");
var idTxtS = charIDToTypeID ("TxtS");
ref62.putProperty (idPrpr, idTxtS);
var idTxLr = charIDToTypeID ("TxLr");
var idOrdn = charIDToTypeID ('Ordn');
var idTrgt = charIDToTypeID ("Trgt");
ref62.putEnumerated (idTxLr, idOrdn, idTrgt);
desc153.putReference (idnull, ref62);
idT var = charIDToTypeID ("T");
var desc154 = new ActionDescriptor();
var idSz = charIDToTypeID ("Sz");
var idPnt = charIDToTypeID ("#Pnt");
desc154.putUnitDouble (idSz, idPnt, crs.fontSize);
var idTxtS = charIDToTypeID ("TxtS");
desc153.putObject (idT, idTxtS, desc154);
executeAction (idsetd, desc153, DialogModes.NO);
}
Help, please.
Thanks in advance.
var desc1 = new ActionDescriptor(), desc2 = new ActionDescriptor(), desc3 = new ActionDescriptor(), ref1 = new ActionReference(); ref1.putEnumerated(charIDToTypeID('TxLr'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt')); desc1.putReference(charIDToTypeID('null'), ref1); desc3.putDouble(stringIDToTypeID("xx"), 2); // width scale desc3.putDouble(stringIDToTypeID("yy"), 1); // height scale desc3.putDouble(stringIDToTypeID("xy"), 0); // skew Y desc3.putDouble(stringIDToTypeID("yx"), 0); // skew X desc3.putDouble(stringIDToTypeID("tx"), 0); // translate by X desc3.putDouble(stringIDToTypeID("ty"), 0); // translate by Y desc2.putObject(charIDToTypeID('Trnf'), charIDToTypeID('Trnf'), desc3); desc1.putObject(charIDToTypeID('T '), charIDToTypeID('TxLr'), desc2); executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
Tags: Photoshop
Similar Questions
-
Simple (I guess) Photoshop scripts quesiton ;)
Hi guys,.
Just a quick question...
I looked on the forum and on the web but cannot find a working solution for my, I think that simple problem.
I have a Photoshop image using variables and external data source (text file) to generate badges with fields such as first_name, last_name, Department,... thanks to this tutorial http://www.richmediacs.com/user_manuals/RMCS_PS_Training/using%20ps%20Variables/UsingVaria blesInPS_EXTERNAL.html (maybe there is a better way to do the same things just scripted).
This part works well but I would add a different logo only for certain Department so I need to use something like "If Department is accounting then show accounting logo of another if Department is engineering genius show another logo display the default logo.
How can I do?
I forgot to say I have this will be my first Photoshop script...
Thank you for your help...
Vince.
With the graphic data and data sets, you have several choices. You may have several layers of logo and use the data to the control that is visible. I think this would be the best way. You can use the dataset object to replace the content of the logo layer. It works best if the logos are the same size. One of the people could be done with simple modifications to the matrix and data sets. You may post-process the images as suggests if you cannot change the data sets.
-
face detection? Photoshop script
Hello
I explored the possibility of automatic detection of faces and selection using photoshop script. Anyone tried something similar? Please guide me in the right direction.
I need find and automatically select the face (with head) and move in different layers.
http://facedetection.jaysalvat.com/ This Web site is Jquery. But I wanted to do with the photoshop script.
mahendrak15024337 wrote:
Thanks JJMack!
Let's say if we leave selection of face. But is there any command/method photoshop script that detects if the layer/image has sides on it or not?
Thanks again!
If you leave the detection of face, how do we know if there is a face or not in a layer. Same Adobe Face detection detects all the faces in the pictures. New face in CC 2015.5 detection liquefy had no problem finding all 8 faces in your example. Yet, I saw portrait images, in that it has failed to identify a face. CC 2015.5 has so many issues, I do not use it. Older versions of Photoshop CS6 starting have face detection in color range to help select the skin.
-
environment variable or registry from a photoshop script
Is there a way to get the environment since a jsx photoshop script variable? (windows) or the registry
Am interested in variable ProgramData (usually C:\programData) as they change in the registry.
Thank you
var s = .getenv ("ProgramData") $;
Don't know how to get the registry entries.
X
-
How the photoshop script can call an applescript script
I realize, maybe it's a bit of a messy way around it, but I need to get the photoshop script to call an applescript script. Basically so that I can have it become a menu item in photoshop.
Is - this show applescript can in the same way photoshop script?
If this isn't the case, I thought I could get either photoshop script to call the applescript or even more messy, I could use Photoshop to run a Terminal command to call the applescript.
All thoughts
Matt
For those who come through it
Save your applescript as an application, and then you can use
App.System ("' open ' / path/to/script_as_an_app.app'" ");
then everything works
-
We you print shirts and often copy and paste the names of player in a model then adjust the horizontal scale, one at a time to fit the text frame (up to 200% not less than 40%). It is a tedious process, and I am sure that there is a way to do it with a script. However I was not able to understand. Any help would be appreciated.
That is down to a certain lateral thinking. How do you define "worthy" or "does not not to?" The following seems to be true, provided your name are the only thing to each its separate text block: not more than 1 single line and not (in part or in whole) in excess.
First of all, a reality check: reduced the text to width 40 percent actually make it fit? If this isn't the case, set the scale to 100% and leave it alone for a human Intervention. Then, it fits all the way up to 200%. We cannot go any wider, we need not resolve anything still don't 'go home' by which meanings. Only if a name is wrapped line, he needs his width adjusted again down.
Here's how it works: select all your text at the same time frames, and then run the script. Then sit because it goes over each picture and adjusts the text to fit with accuracy up to 0.1%
I have prepared a picture to show what it looks like - Fanny Blankers-Koen, Dutch skating pride, was chosen to be the "too long" name to show that the script is not in what it can not solve, and Ali, pele and Louis (Joe, of course!) show that it go not beyond 200%.
Oh and here's the Javascript code:
//DESCRIPTION:Multi-text-frame-fit // A Jongware Script 07-Apr-2015 for (i=0; i
1) ft.horizontalScale = 100; else { // calc what should fit ft.horizontalScale = 200; // still not there at 200? Leave it, else try smaller if (f.overflows || ft.lines.length > 1) { while (f.overflows || ft.lines.length > 1) ft.horizontalScale -= 10; ft.horizontalScale += 10; while (f.overflows || ft.lines.length > 1) ft.horizontalScale -= 1; ft.horizontalScale += 1; while (f.overflows || ft.lines.length > 1) ft.horizontalScale -= 0.1; } } } -
Is there a console or a log output of script event? I tried to make a function that performs an alert correctly, but does not create a new document. I can't find is it possible to see if this syntax is incorrect or the command is just outdated.
In the code below, for example, I see the alert message, but no new document. I don't see anyway to see what the problem with him and I pulled this line directly from the photoshop scripting guide.
createDocument var = function() {}
Alert ("create new doc!");
App.Documents.Add (2.4);
};
IMHO, I don't think so. (I don't have none of that.)
Maybe I understand you only hurts.
The only thing you could do - own messages they close again by itself.
Something like this:
// CreateNewDocAndShowMessage.jsx // http://forums.adobe.com/thread/1237214?tstart=0 // regards pixxxelschubser var Call; createDocument (); function createDocument () { Call = "creating new doc!"; CallFunction (); app.documents.add (40,40); } function CallFunction () { win = new Window ("palette"); win.someMessage= win.add ("statictext", undefined, Call); win.show(); $.sleep(1500); win.close(); }
-
Creation of text numbered/uces in Photoshop.
Hello, I was wondering if it is posible to create text / bulleted, numbered in photoshop, with indentation as is done in MS Word.
I tried the paragraph palette, but I can't do indentation by one line:
I wanted to do something like this:
Just something like the text that appears on the left of the image of this House. The image shows the different components of a system of distribution of water for a unique home that collects rain water and deposits it in a storage tank. The only text I wrote in photoshop is the title and web address.
It's a few notes of course, but I wanted to replace the original digitized text (which is dark blue) for some photoshop in black text. But I want the text with the same format of dash. Is this possible in Photoshop?
Could someone please help?
Please read my investigation.
Photoshop cannot automatically generate a numbered list. As stalion_two said, you're probably better off using a word processor.
Try entering a negative value on the first indented line, as shown below. You may need to adjust this number according to which type/size/weight of font that you are using. You can see it reproduced the setting back in the screenshot you provided.
-
How to add a color sample in a Photoshop script?
Hello
I would like to set a point of color sampler in a Photoshop script?
Could you please help me on this.
Thank you
Rajiv.s
var theSampler = app.activeDocument.colorSamplers.add([10,10]);
Alert (theSampler.color.rgb.red + "_" + theSampler.color.rgb.green + "_" + theSampler.color.rgb.blue);
Edit: And don't forget that a document can have only four ColorSamplers (from CS5 at least).
-
Adding text to placeholder in Photoshop CS4
Hello
Hope this finds you well.
Does anyone know how to add text to placeholder in Photoshop cs4?
I appreciate your time and look forward to hearing back from you soon.
There is no built-in as in InDesign (Photoshop is not a page layout program, after all. If you set up large quantities of copy of body that you are using the wrong tool for the job...).
Locate a placeholder text. This is one of the many links Google returns:
Copy and paste into Photoshop.
-
Photoshop Script add name of Image file as text, but remove '-' character
I found a script that will take the name of my image file and place it on the image, less file extension. I added this to an action, which works exactly how I want, but my filenames have '-' characters in them.
Is it possible to remove the '-' characters of the script? I was not able to get the function replace to work. (that I need).
This is the code that works right now:
// Now create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
// strip the extension off
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");
myTextRef.contents = fileNameNoExtension.substring(2);
// myTextRef.contents = fileNameNoExtension.replace(/^-/i, '');
// off set the text to be in the middle
myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
myTextRef.size = 28;
}myTextRef.contents = fileNameNoExtension.replace (/-/ g, ");
-
Photoshop script to copy all the layers of close PSD to open the current document
Hi, I have very limited capacity script so this task is above my pay grade
I'm looking for a script to read and copy all the layers in a PSD saved file and copy them into the current active document. The two documents have the same size and I need to be able to change text layers after copying. Anyone has any advice or examples of how I might be able to do this?
Thank you in advance for any help you can offer.
Kind regards
Marcus
Try the script in entry below. You must open the destination file, and you must put in the path and name where your source file. It will not choose a layer from background from the source file.
#target photoshop var sFile = new File('~/desktop/template.psd');//change path to template file var doc = activeDocument; var sDoc = open(sFile); var idselectAllLayers = stringIDToTypeID( "selectAllLayers" ); var desc2 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref1 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref1.putEnumerated( idLyr, idOrdn, idTrgt ); desc2.putReference( idnull, ref1 ); executeAction( idselectAllLayers, desc2, DialogModes.NO ); var idDplc = charIDToTypeID( "Dplc" ); var desc5 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref2 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref2.putEnumerated( idLyr, idOrdn, idTrgt ); desc5.putReference( idnull, ref2 ); var idT = charIDToTypeID( "T " ); var ref3 = new ActionReference(); var idDcmn = charIDToTypeID( "Dcmn" ); ref3.putName( idDcmn, doc.name ); desc5.putReference( idT, ref3 ); var idVrsn = charIDToTypeID( "Vrsn" ); desc5.putInteger( idVrsn, 5 ); var idIdnt = charIDToTypeID( "Idnt" ); var list1 = new ActionList(); list1.putInteger( 3 ); list1.putInteger( 4 ); desc5.putList( idIdnt, list1 ); executeAction( idDplc, desc5, DialogModes.NO );
-
Hi, I would need your help. I want to customize this code it will automatically run when I launch immediately click OK plus. Thank you very much.
#target photoshop /********************************************************************* Batch HDR Script by David Milligan *********************************************************************/ /********************************************************************* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. **********************************************************************/ /* // BEGIN__HARVEST_EXCEPTION_ZSTRING <javascriptresource> <name>Batch HDR...</name> <menu>automate</menu> </javascriptresource> // END__HARVEST_EXCEPTION_ZSTRING */ //these lines import the 'Merge To HDR.jsx' script that is built in to photoshop, we will make calls to that script and some of the scripts that it includes var runMergeToHDRFromScript = true; var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"); var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' ); $.evalFile( g_ScriptPath ); //$.level = 2; //default settings: mergeToHDR.useAlignment = true; mergeToHDR.useACRToning = false; var numberOfBrackets = 3; var userCanceled = false; var sourceFolder = new Folder('/d/Automata/LOADING');; var outputFolder = new Folder('/d/Automata/LOADING');; var saveType = "JPEG"; var jpegQuality = 80; var progress; var statusText; var progressWindow; var fileMask = "*"; var outputFilename = "hdr_output_"; var zeroPadding = 2; var hdrRadius = 100; var hdrStrength = 0.5; var hdrGamma = 1.0; var hdrExposure = 0.0; var hdrDetail = 100; var hdrShadow = 0; var hdrHighlights = 0; var hdrVibrance = 20; var hdrSaturation = 30; var hdrSmooth = false; var hdrDeghosting = kMergeToHDRDeghostBest;//kMergeToHDRDeghostOff var hdrCurve = "0,0,255,255"; var estTimeRemaining = ""; var previewDoc; var originalDoc; function main() { promptUser(); //make sure user didn't cancel if(sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists && numberOfBrackets > 0) { initializeProgress(); var files = sourceFolder.getFiles(fileMask); files.sort(); var currentFileList = new Array(); var numberOfFiles = files.length; if (numberOfFiles % 3 == 0) { numberOfBrackets = 3; } else { numberOfBrackets = 2; } /* convert numberOfFiles to a string to make sure zeropaddingis high enough to cover all files */ var numberOfFilesStr = "" + (numberOfFiles / numberOfBrackets); if (zeroPadding > 0 && zeroPadding < numberOfFilesStr.length) { zeroPadding = numberOfFilesStr.length; } for(var index = 0; index < numberOfFiles; index++) { if((index % numberOfBrackets) == numberOfBrackets - 1) { var start = new Date(); progress.value = 100 * index / numberOfFiles; currentFileList.push(files[index]); if(userCanceled) break; if(numberOfBrackets > 1) { statusText.text = "Merging files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+numberOfFiles + estTimeRemaining; //for braketed exposures use the mergeToHDR script to merge the files into a single 32 bit image mergeToHDR.outputBitDepth= 32; mergeToHDR.mergeFilesToHDR( currentFileList, mergeToHDR.useAlignment, hdrDeghosting ); statusText.text = "Toning files "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+numberOfFiles+ estTimeRemaining; } else { statusText.text = "Loading file "+(index+1)+" of "+numberOfFiles+ estTimeRemaining; //otherwise just open the file doOpenFile(files[index]); statusText.text = "Toning file "+(index+1)+" of "+numberOfFiles+ estTimeRemaining; } progress.value = 100 * (index + numberOfBrackets / 2 ) / numberOfFiles; if(userCanceled) break; try { if(app.activeDocument != null && outputBitDepth < 32) { //apply the actual tone mapping to the HDR image to get it back down to 8 bits doHDRToning(); } } catch(error) { alert(error + "\nCheck number of files in source folder"); break; } //save the result and close //TODO: add leading zeros to index in filename if(numberOfBrackets > 1) { statusText.text = "Saving result "+(index-numberOfBrackets+2)+" - "+(index+1)+" of "+numberOfFiles+ estTimeRemaining; } else { statusText.text = "Saving result "+(index+1)+" of "+numberOfFiles+ estTimeRemaining; } if(userCanceled) break; doSaveFile(outputFolder.absoluteURI + "/" + outputFilename + ZeroPad(Math.round((index + 1)/numberOfBrackets), zeroPadding) ); activeDocument.close(SaveOptions.DONOTSAVECHANGES); //reset our file list currentFileList = new Array(); //calculate time remaining var end = new Date(); var timeElapsed = end.getTime() - start.getTime(); var mins = timeElapsed / 60000 * ((numberOfFiles - index - 1) / numberOfBrackets); estTimeRemaining = " | Remaining: " + ZeroPad((mins / 60).toFixed(0),2) + ":" + ZeroPad((mins % 60).toFixed(0),2); } else { currentFileList.push(files[index]); } } progressWindow.hide(); } } function doOpenFile(filename) { const eventOpen = app.charIDToTypeID('Opn '); var desc = new ActionDescriptor(); desc.putPath( typeNULL, new File( filename ) ); desc.putBoolean( kpreferXMPFromACRStr, true ); //not sure what this does or if it is needed executeAction( eventOpen, desc, DialogModes.NO ); //if we don't convert the image to 32bit the mergeToHDR script will not tone our image when we call it, it will simply downconvert it to 8 bit convertTo32Bit (); } function convertTo32Bit() { var idCnvM = charIDToTypeID( "CnvM" ); var desc6 = new ActionDescriptor(); var idDpth = charIDToTypeID( "Dpth" ); desc6.putInteger( idDpth, 32 ); var idMrge = charIDToTypeID( "Mrge" ); desc6.putBoolean( idMrge, false ); var idRstr = charIDToTypeID( "Rstr" ); desc6.putBoolean( idRstr, false ); executeAction( idCnvM, desc6, DialogModes.NO ); } function doSaveFile(filename) { if(saveType == "JPEG") { var jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.embedColorProfile = true; jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; jpgSaveOptions.matte = MatteType.NONE; jpgSaveOptions.quality = jpegQuality; activeDocument.saveAs(new File(filename), jpgSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/); } else if(saveType == "TIFF") { var tifSaveOptions = new TiffSaveOptions(); tifSaveOptions.embedColorProfile = true; activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/); } else if(saveType == "TIFF LZW") { var tifSaveOptions = new TiffSaveOptions(); tifSaveOptions.embedColorProfile = true; tifSaveOptions.imageCompression = TIFFEncoding.TIFFLZW; activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/); } else if(saveType == "TIFF ZIP") { var tifSaveOptions = new TiffSaveOptions(); tifSaveOptions.embedColorProfile = true; tifSaveOptions.imageCompression = TIFFEncoding.TIFFZIP; activeDocument.saveAs(new File(filename), tifSaveOptions, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/); } else { activeDocument.saveAs(new File(filename), undefined, true /*Save As Copy*/, Extension.LOWERCASE /*Append Extention*/); } } function doHDRToning() { //create the ActionDescriptor that describes the HDR toning settings to use var hdDesc = new ActionDescriptor; hdDesc.putInteger( stringIDToTypeID( 'version' ), 6 );//I'm not sure what this does hdDesc.putInteger( kmethodStr, 3 );// the toning method to use, 3 = local adaptation hdDesc.putDouble( stringIDToTypeID( 'radius' ), hdrRadius ); hdDesc.putDouble( stringIDToTypeID( 'threshold' ), hdrStrength );// strength hdDesc.putDouble( stringIDToTypeID( 'center' ), hdrGamma );// gamma hdDesc.putDouble( stringIDToTypeID( 'brightness' ), hdrExposure );// exposure hdDesc.putDouble( stringIDToTypeID( 'detail' ), hdrDetail ); hdDesc.putDouble( stringIDToTypeID( 'shallow' ), hdrShadow ); hdDesc.putDouble( stringIDToTypeID( 'highlights' ), hdrHighlights ); hdDesc.putDouble( stringIDToTypeID( 'vibrance' ), hdrVibrance ); hdDesc.putDouble( stringIDToTypeID( 'saturation' ), hdrSaturation); hdDesc.putBoolean( stringIDToTypeID( 'smooth' ), hdrSmooth ); hdDesc.putBoolean( stringIDToTypeID( 'deghosting' ), hdrDeghosting ); //create the tone curve var cDesc = new ActionDescriptor; cDesc.putString( stringIDToTypeID( 'name' ), 'Default'); var cList = new ActionList; var points = hdrCurve.split(','); for(var i = 0; i < points.length; i++) { if(i % 2 == 1) { var pDesc = new ActionDescriptor; pDesc.putDouble( stringIDToTypeID( 'horizontal' ), points[i-1] ); pDesc.putDouble( stringIDToTypeID( 'vertical' ), points[i] ); pDesc.putBoolean( keyContinuity , false );// ????? cList.putObject( charIDToTypeID( 'Pnt ' ), pDesc ); } } cDesc.putList( stringIDToTypeID( 'curve' ), cList ); hdDesc.putObject( kclassContour, classShapingCurve, cDesc ); //call the script that actually invokes the toning plugin convertFromHDRNoDialog( outputBitDepth, hdDesc ); } function initializeProgress() { progressWindow = new Window("palette { text:'Meilleure Visite Chargement', \ statusText: StaticText { text: 'Processing Images...', preferredSize: [350,20] }, \ progressGroup: Group { \ progress: Progressbar { minvalue: 0, maxvalue: 100, value: 0, preferredSize: [300,20] }, \ cancelButton: Button { text: 'Cancel' } \ } \ }"); statusText = progressWindow.statusText; progress = progressWindow.progressGroup.progress; progressWindow.progressGroup.cancelButton.onClick = function() { userCanceled = true; } progressWindow.show(); } function promptUser() { var setupWindow = new Window("dialog { orientation: 'row', text: 'Meilleure Visite', alignChildren:'top', \ leftGroup: Group { orientation: 'column', alignChildren:'fill', \ inputPanel: Panel { text: 'Input', \ sourceGroup: Group { \ }, \ bracketGroup: Group{ \ bracketLabel: StaticText { text: 'Number of Brackets: ' }, \ bracketBox: EditText { characters: 2 }, \ filterLabel: StaticText { text: 'File Filter: ' }, \ filterText: EditText { characters: 5 }, \ alignCheckBox: Checkbox { text: 'Align' }\ deghostLabel: StaticText { text: 'Deghost: ' }\ deghostDropDown: DropDownList { }, \ } \ }, \ toningPanel: Panel { text: 'Toning', orientation:'row', alignChildren:'top' } ,\ outputPanel: Panel { text: 'Output', \ outputGroup: Group { \ outputBox: EditText { characters: 10, text: '', enabled:false }, \ }, \ outputOptionsGroup: Group { \ outputFilenameLabel: StaticText { text: 'Filename Format: ' }, \ outputFilenameText: EditText { characters: 10 }, \ }, \ saveSettingsGroup: Group { \ saveTypeLabel: StaticText { text: 'Save As: ' }, \ saveDropDown: DropDownList { }, \ jpegQualityLabel: StaticText { text: 'JPEG Quality (1-10): ' }, \ jpegQualityText: EditText { characters: 2}, \ outputBitDepthLabel: StaticText { text: 'Bit Depth', enabled:false }, \ outputBitDepthDropDown: DropDownList { enabled:false }, \ } \ } \ }, \ rightGroup: Group { orientation: 'column', alignChildren:'fill', \ okButton: Button { text: 'OK', enabled: true } \ cancelButton: Button { text: 'Cancel' } \ } \ } "); generateToningPanel(setupWindow.leftGroup.toningPanel); //shortcut variables var sourceBox = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBox; var sourceBrowse = setupWindow.leftGroup.inputPanel.sourceGroup.sourceBrowse; var bracketBox = setupWindow.leftGroup.inputPanel.bracketGroup.bracketBox; var filterText = setupWindow.leftGroup.inputPanel.bracketGroup.filterText; var alignCheckBox = setupWindow.leftGroup.inputPanel.bracketGroup.alignCheckBox; var outputBox = setupWindow.leftGroup.outputPanel.outputGroup.outputBox; var outputFilenameText = setupWindow.leftGroup.outputPanel.outputOptionsGroup.outputFilenameText; var outputFilenamePost = setupWindow.leftGroup.outputPanel.outputOptionsGroup.outputFilenamePost; var saveDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.saveDropDown; var jpegQualityText = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityText; var jpegQualityLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.jpegQualityLabel; var outputBitDepthDropDown = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthDropDown; var outputBitDepthLabel = setupWindow.leftGroup.outputPanel.saveSettingsGroup.outputBitDepthLabel; var okButton = setupWindow.rightGroup.okButton; var cancelButton = setupWindow.rightGroup.cancelButton; var toningPanel = setupWindow.leftGroup.toningPanel; var deghostDropDown = setupWindow.leftGroup.inputPanel.bracketGroup.deghostDropDown; //set default values bracketBox.text = numberOfBrackets; filterText.text = fileMask; //mergeToHDR.useAlignment = true; alignCheckBox.value = mergeToHDR.useAlignment; outputFilenameText.text = outputFilename; jpegQualityText.text = jpegQuality; saveDropDown.add("item", "TIFF"); saveDropDown.add("item", "JPEG"); saveDropDown.add("item", "TIFF LZW"); saveDropDown.add("item", "TIFF ZIP"); saveDropDown.selection = 0; outputBitDepthDropDown.add("item", "8"); outputBitDepthDropDown.add("item", "16"); outputBitDepthDropDown.add("item", "32"); outputBitDepthDropDown.selection = 0; var generateDeghostDropDownList = function(count) { deghostDropDown.removeAll() deghostDropDown.add("item", "Best"); deghostDropDown.add("item", "Off"); for(var i = 0; i < count; i++) { deghostDropDown.add("item", i); } deghostDropDown.selection = 0; } generateDeghostDropDownList(numberOfBrackets); //event handlers bracketBox.onChange = function() { numberOfBrackets = bracketBox.text; generateDeghostDropDownList(numberOfBrackets); }; filterText.onChange = function() { fileMask = filterText.text; }; alignCheckBox.onClick = function() { mergeToHDR.useAlignment = alignCheckBox.value; }; deghostDropDown.onChange = function() { if(this.selection.text == "Best") hdrDeghosting = kMergeToHDRDeghostBest; else if(this.selection.text == "Off") hdrDeghosting = kMergeToHDRDeghostOff; else hdrDeghosting = Number(this.selection.text); }; outputBox.onChange = function() { outputFolder = new Folder(outputBox.text); okButton.enabled = sourceFolder != null && outputFolder != null && sourceFolder.exists && outputFolder.exists; }; outputFilenameText.onChange = function() { outputFilename = outputFilenameText.text; }; saveDropDown.onChange = function() { saveType = saveDropDown.selection.text; jpegQualityText.enabled = saveDropDown.selection.text == "JPEG"; jpegQualityLabel.enabled = saveDropDown.selection.text == "JPEG"; if(saveDropDown.selection.text == "JPEG") { outputBitDepthDropDown.selection = 0; } outputBitDepthDropDown.enabled = saveDropDown.selection.text != "JPEG" && saveDropDown.selection.text != "Radiance" && saveDropDown.selection.text != "OpenEXR"; outputBitDepthLabel.enabled = outputBitDepthDropDown.enabled; }; jpegQualityText.onChange = function() { jpegQuality = jpegQualityText.text; }; outputBitDepthDropDown.onChange = function() { outputBitDepth = outputBitDepthDropDown.selection.text; toningPanel.enabled = outputBitDepth != 32; } okButton.onClick = function() { setupWindow.hide(); cleanUpPreviews(); }; cancelButton.onClick = function() { sourceFolder = null, setupWindow.hide(); cleanUpPreviews(); }; saveDropDown.onChange(); outputBitDepthDropDown.onChange(); setupWindow.show(); } function cleanUpPreviews() { if(originalDoc != null) { originalDoc.close(SaveOptions.DONOTSAVECHANGES); originalDoc = null; } if(previewDoc != null) { previewDoc.close(SaveOptions.DONOTSAVECHANGES); previewDoc = null; } } function generateToningPanel(toningPanel) { var leftToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}"); var rightToningGroup = toningPanel.add("group{orientation:'column',alignChildren:'fill'}"); var presetGroup = leftToningGroup.add("group{orientation:'row'}"); var presetDropDown = presetGroup.add("dropdownlist"); var loadPresetButton = presetGroup.add("button", undefined, "Load Preset"); var edgePanel = leftToningGroup.add("panel",undefined,"Edge Glow"); var radiusSlider = createSliderControl(edgePanel.add("group"), " Radius: ", "px", 0, 500, 0, hdrRadius, function(newValue){ hdrRadius = newValue; }); var strengthSlider = createSliderControl(edgePanel.add("group"), "Strength: ", "", 0, 4.0, 2, hdrStrength, function(newValue){ hdrStrength = newValue; }); var edgeGroup = edgePanel.add("group"); var smoothEdgesBox = edgeGroup.add("checkbox",undefined, "Smooth Edges"); var detailPanel = leftToningGroup.add("panel",undefined,"Tone and Detail"); var gammaSlider = createSliderControl(detailPanel.add("group"), " Gamma: ", "", 0.1, 2.0, 2, hdrGamma, function(newValue){ hdrGamma = newValue; }); var exposureSlider = createSliderControl(detailPanel.add("group"), "Exposure: ", "", -5.0, 5.0, 2, hdrExposure, function(newValue){ hdrExposure = newValue; }); var detailSlider = createSliderControl(detailPanel.add("group"), " Detail: ", "%", -300, 300, 0, hdrDetail, function(newValue){ hdrDetail = newValue; }); var advancedPanel = leftToningGroup.add("panel",undefined,"Advanced"); var shadowSlider = createSliderControl(advancedPanel.add("group"), " Shadow: ", "%", -100, 100, 0, hdrShadow, function(newValue){ hdrShadow = newValue; }); var highlightSlider = createSliderControl(advancedPanel.add("group"), " Highlight: ", "%", -100, 100, 0, hdrHighlights, function(newValue){ hdrHighlights = newValue; }); var vibranceSlider = createSliderControl(advancedPanel.add("group"), " Vibrance: ", "%", -100, 100, 0, hdrVibrance, function(newValue){ hdrVibrance = newValue; }); var saturationSlider = createSliderControl(advancedPanel.add("group"), "Saturation: ", "%", -100, 100, 0, hdrSaturation, function(newValue){ hdrSaturation = newValue; }); var toningCurvePanel = leftToningGroup.add("panel{text:'Toning Curve',alignChildren:'fill'}"); var curveBox = toningCurvePanel.add("edittext", undefined, hdrCurve); //default values smoothEdgesBox.value = hdrSmooth; var presetFiles = getPresetFiles(); var updateSliders = function() { radiusSlider(hdrRadius); strengthSlider(hdrStrength); smoothEdgesBox.value = hdrSmooth; exposureSlider(hdrExposure); gammaSlider(hdrGamma); detailSlider(hdrDetail); shadowSlider(hdrShadow); highlightSlider(hdrHighlights); vibranceSlider(hdrVibrance); saturationSlider(hdrSaturation); curveBox.text = hdrCurve; } if(presetFiles.length > 0) { for(var f in presetFiles) { presetDropDown.add("item", presetFiles[f].displayName.replace(".hdt","")); } presetDropDown.selection = 0; loadPreset(presetFiles[0]); presetDropDown.onChange = function() { loadPreset(presetFiles[presetDropDown.selection.index]); updateSliders(); }; } //event handlers loadPresetButton.onClick = function() { loadPreset(null); updateSliders(); }; smoothEdgesBox.onClick = function () { hdrSmooth = smoothEdgesBox.value; }; curveBox.onChange = function () { hdrCurve = curveBox.text; }; updateSliders(); } function createSliderControl(group,label,postLabel,min,max,round,value,onValueChanged) { var ignoreChange = false; group.add("statictext", undefined, label); var slider = group.add("slider",undefined,value,min,max); slider.alignment = "fill"; var box = group.add("edittext",undefined,value); box.characters = 6; group.add("statictext", undefined, postLabel); slider.onChange = function() { if(!ignoreChange) { ignoreChange = true; box.text = slider.value.toFixed(round); onValueChanged(slider.value); ignoreChange = false; } }; box.onChange = function() { if(!ignoreChange) { ignoreChange = true; slider.value = box.text; onValueChanged(box.text); ignoreChange = false; } }; return function(newValue) { slider.value = newValue; box.text = newValue.toFixed(round); }; } //forces a redraw while a script dialog is active (for preview) var waitForRedraw = function() { var desc = new ActionDescriptor(); desc.putEnumerated(charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm")); executeAction(charIDToTypeID("Wait"), desc, DialogModes.NO); } function getZoomLevel() { var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var desc = executeActionGet(ref); return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1); } function setZoomLevel( zoom ) { if(zoom < 1 ) zoom =1; var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72; var docRes = activeDocument.resolution; activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE ); var desc = new ActionDescriptor(); ref = null; ref = new ActionReference(); ref.putEnumerated( charIDToTypeID( "Mn " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) ); desc.putReference( charIDToTypeID( "null" ), ref ); executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE ); } function ZeroPad(number,numZeros) { var result = number.toString(); while(result.length < numZeros) { result = "0" + result; } return result; } var getPresetFiles = function() { var presetFolder = new Folder(app.path + "/Presets/HDR Toning"); return presetFolder.getFiles("*.hdt"); } var loadPreset = function(presetFile) { if(presetFile == null) { presetFile = File.openDialog("Select Preset","*.hdt"); } if(presetFile != null) { var tmpStr = new String(); var binaryData = new Array(); presetFile.encoding = "BINARY"; presetFile.open('r'); while(!presetFile.eof) { var ch = presetFile.readch(); if ( ch.charCodeAt(0) == 0 ){ tmpStr += ' '; } else { tmpStr += ch; } binaryData.push(ch.charCodeAt(0)); } presetFile.close(); if(binaryData.length >= 40) { // init start position for reading datas // start position for english version ( string "D e f a u l t" is in the preset file ) var startPos = 38; if ( tmpStr.search ("P a r d é f a u t") > -1 ){ // start position for french preset file version ( string "P a r d é f a u t" is in the preset file ) (==> + 6 bytes) startPos = 44; } // if your preset file can't be read, try this : open it in notepad to see the string "D e f a u l t" in your language and add the code here to set startPos to 38 + diff between the length of ("D e f a u l t") and length of ("D e f a u l t" in your language) var curvePointCount = getUInt16(binaryData, startPos); if(binaryData.length >= 104 + curvePointCount * 4) { var curvePointStr = ""; for(var i = 0; i < curvePointCount; i++) { curvePointStr += getUInt16(binaryData, startPos + 4 + i * 4) + "," + getUInt16(binaryData, startPos + 2 + i * 4) + ((i < curvePointCount - 1) ? "," : ""); } hdrCurve = curvePointStr; hdrStrength = getFloat32(binaryData,8); hdrRadius = getFloat32(binaryData, startPos + 10 + 5 * curvePointCount); hdrExposure = getFloat32(binaryData, startPos + 34 + 5 * curvePointCount); hdrSaturation = getFloat32(binaryData, startPos + 38 + 5 * curvePointCount); hdrDetail = getFloat32(binaryData, startPos + 42 + 5 * curvePointCount); hdrShadow = getFloat32(binaryData, startPos + 46 + 5 * curvePointCount); hdrHighlights = getFloat32(binaryData, startPos + 50 + 5 * curvePointCount); hdrGamma = getFloat32(binaryData, startPos + 54 + 5 * curvePointCount); hdrVibrance = getFloat32(binaryData, startPos + 58 + 5 * curvePointCount); hdrSmooth = getUInt16(binaryData, startPos + 62 + 5 * curvePointCount) != 0; } else { alert("Error Loading File", "Error", true); } } else { alert("Error Loading File", "Error", true); } } } function getUInt16(byteArray,offset) { return byteArray[offset] * 0x100 + byteArray[offset + 1]; } function getUInt32(byteArray,offset) { return byteArray[offset] * 0x1000000 + byteArray[offset + 1] * 0x10000 + byteArray[offset + 2] * 0x100 + byteArray[offset + 3]; } function getFloat32(byteArray,offset) { var bytes = getUInt32(byteArray,offset); var sign = (bytes & 0x80000000) ? -1 : 1; var exponent = ((bytes >> 23) & 0xFF) - 127; var significand = (bytes & ~(-1 << 23)); if (exponent == 128) return sign * ((significand) ? Number.NaN : Number.POSITIVE_INFINITY); if (exponent == -127) { if (significand == 0) return sign * 0.0; exponent = -126; significand /= (1 << 22); } else significand = (significand | (1 << 23)) / (1 << 23); return sign * significand * Math.pow(2, exponent); } main();
I do not support exhibitions in order to perform processing HDR. I don't want to create HDR images. The EXIF data does not have an EV adjustment. You can calculate EV information EXIF information. Should the process of HDR data EXIF to calculate EV your image file need to have then the metadata. Your script can be able to be something for the HDR script, I have no idea what the deghostFlag is all. Maybe if you examine the code in the script of David Milligan you can very well how to use the HDR script from another script.
-
Photoshop script to export groups as folders?
Hello
I work with a .psb file that has about 100 groups with layers in them. I would like to export these groups into folders containing a file .png for each individual layer inside. If I create the folders manually and reorganize the files png inside of them, it would take me several hours. I can't find a script that works. Any ideas? Thank you much in advance.
This script will create a folder for the file name and the groupnames with png files.
#target photoshop; app.bringToFront(); main(); function main(){ if(!documents.length) return; try{ var doc = app.activeDocument; app.displayDialogs = DialogModes.NO; pngSaveOptions = new PNGSaveOptions(); var LSets = getLayerSets(); if(LSets.length < 1) return; try{ var Name = doc.name.replace(/\.[^\.]+$/, ''); var docPath = doc.path; }catch(err){ alert("This document needs to be saved before running this script!"); return; } var OutputPath = Folder(docPath + "/" + Name); if(!OutputPath.exists) OutputPath.create(); for(var f in LSets){ var LayerSetIndexs = getChildIndex(Number(LSets[f][0]),false); var groupFolder = Folder(OutputPath + "/" + LSets[f][1].toString()); if(!groupFolder.exists) groupFolder.create(); for(var x in LayerSetIndexs){ selectLayerByIndex(Number(LayerSetIndexs[x])); var Kind = activeDocument.activeLayer.kind; var Shape = isShapeLayer(); if(Kind ==LayerKind.NORMAL || Kind == LayerKind.SMARTOBJECT || Kind == LayerKind.TEXT || Shape == true){ dupLayers(); var saveFile = File(groupFolder + "/" + activeDocument.activeLayer.name + ".png"); activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); }else{ continue; } } } }catch(e){} }; function isShapeLayer(){ var ref = new ActionReference(); ref.putEnumerated( charIDToTypeID('Lyr '),charIDToTypeID('Ordn'),charIDToTypeID('Trgt') ); desc = executeActionGet(ref); if(!desc.hasKey(stringIDToTypeID('adjustment')) ) return false; if(desc.getBoolean(stringIDToTypeID('hasVectorMask' )) == true) return true; return false; }; function getLayerLayerSectionByIndex( index ) { var ref = new ActionReference(); ref.putIndex(charIDToTypeID('Lyr '), index); return typeIDToStringID(executeActionGet(ref).getEnumerationValue(stringIDToTypeID('layerSection'))); }; function getLayerNameByIndex( index ) { var ref = new ActionReference(); ref.putIndex( charIDToTypeID( 'Lyr ' ), index ); return executeActionGet(ref).getString(charIDToTypeID( 'Nm ' )); }; function skipNestedSets( layerIndex ){ var isEnd = false; layerIndex = app.activeDocument.layers[app.activeDocument.layers.length-1].isBackgroundLayer ? layerIndex-2:layerIndex; while(!isEnd){ layerIndex--; if( getLayerLayerSectionByIndex( layerIndex ) == 'layerSectionStart' ) layerIndex = skipNestedSets( layerIndex ); isEnd = getLayerNameByIndex(layerIndex) == '' ? true:false; } return layerIndex-1; }; function getChildIndex(idx, skipNested ){ var layerSetIndex = idx; var isEndOfSet = false; var layerIndexArray = []; while(!isEndOfSet){ layerSetIndex--; if( getLayerLayerSectionByIndex( layerSetIndex ) == 'layerSectionStart' && skipNested ){ layerSetIndex = skipNestedSets( layerSetIndex ); } if(getLayerLayerSectionByIndex( layerSetIndex ) == undefined) break; isEndOfSet = getLayerNameByIndex(layerSetIndex) == '' ? true:false; if(!isEndOfSet ) layerIndexArray.push( layerSetIndex ); } return layerIndexArray; }; function getLayerSets(){ var ref = new ActionReference(); ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( 'NmbL' )); ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1; var Names=[]; try{ activeDocument.backgroundLayer; var i = 0; }catch(e){ var i = 1; }; for(i;i
-
Sales questions of Photoshop scripts...
Hi people,
I'll be direct with my questions and as sincere as possible.
Can I sell scripts I'll give for Photoshop, but don't own Photoshop? Am I allowed to test my scripts on another PC in a Photoshop license?
Am I allowed to sell scripts decoration made by me?
If this is not the case, what I have to do regarding have the right to sell my scripts?
P.S. I'm not in a position to pay membership for Photoshop, because I need to pay the price "NASA funding project" of my country, and it is impossible to pay directly online on the Adobe website, where it is much more affordable. I chose Photoshop because the market is pointing in this direction.
Thank you
You don't need Photoshop to be able to sell your scripts. You can sell standard and Deco scripts.
Maybe you are looking for
-
Satellite A-L50-1CU-BT cannot find other BT devices
Hello Today, after months, it was the first time I tried to use bt to transfer files to a mobile phone: bt is active on the l50 and two different mobile phones (android and they are visible and can connect and transfer files an eachother).But the L50
-
matter of timing in a signal to simulate (exit DaqAssistant)
Hi, I was working on a wave form simulating the box to exit DAQ Assistant (try to generate the sinusoidal waveform amplifier) and... for some reason, I can't run my program I thought that if I put the DAQ assistant to be "On Demand" should be all he
-
I had a problem, which lead to the other. I'll just show what I posted in the other thread. Thus, I have provided the link for reference. This is the excerpt from this thread: http://social.answers.microsoft.com/Forums/en/vistawu/thread/a42818dc-4037
-
Try to install Skype I got an error message (see below) and had to quit the installer. Error message: the drive or the UNC share, you have selected does not exist or is not accessible. Please select another. I did not select a player and do not know
-
My small screen touch Pavilion gives me the error that the main battery isn't good after only little more than a year of use. I want to watch reminders, etc., but I don't see no model # on the body of the device. The background comes from the 'trad