Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all 12244 articles
Browse latest View live

Photoshop scripting, export to png?

$
0
0

I use the following code:

 

function SavePNG(saveFile){

  var opts = new ExportOptionsSaveForWeb();

  opts.format = SaveDocumentType.PNG;

  opts.PNGB = true;

  opts.quality = 100;

  pngFile = new File(saveFile);

  opts.includeProfile = true;

  app.activeDocument.exportDocument(pngFile, ExportType.SAVEFORWEB, opts);

}

 

It almost workable, but it works with fully visible or fully invisible areas only. For example if I have a transparent layer and add a second transparent layer with a red rect with opacity 50%, then I will got an image where the transparency of this rect is 100% (fully visible).

 

How to solve this problem? I use Photoshop CS6 (Mac OS version).


I have a script that works on all the machines in my office except one can someone help me?

$
0
0

Most of the machines in my studio are running cs5.5 or cs6 but one machine is running 5.1 - we have been using this script on all the machines:

 

#target photoshop

function main(){

if(documents.length != 1) return;

// Open psd with the layers to copy

var PSD = new File("/Applications/Adobe Photoshop CS6/Presets/Scripts/Script_Resources/moreLengthsOverlayTemplate.psd") ;

if(!PSD.exists) return;

open(PSD);

selectAllLayers();

activeDocument.activeLayer.duplicate(documents[0]);

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

}

function selectAllLayers() {

var desc29 = new ActionDescriptor();

var ref23 = new ActionReference();

ref23.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc29.putReference( charIDToTypeID('null'), ref23 );

executeAction( stringIDToTypeID('selectAllLayers'), desc29, DialogModes.NO );

}

main();

 

but i have one troublesome machine that is giving me issues.

here are some screen shots to illustrate what is happening:

Screen Shot 2013-05-30 at 11.05.37 AM.png

Screen Shot 2013-05-30 at 11.07.23 AM.pngScreen Shot 2013-05-30 at 11.07.38 AM.png

I'm not terribly script saavy and I am not sure if this is just because the machine in question is running cs5.1 or if theres some other problem.

Thanks for your help!

doc.resizeImage based on percentage? is this possible

$
0
0

Is there a way to use the "doc.resizeImage" function but resize based on percentage? 

 

I've tried the follow but I get errors...

 

doc.resizeImage(UnitValue(0.50,"%"),UnitValue(0.50,"%"),null,ResampleMethod.BICUBIC);

doc.resizeImage(UnitValue(50,"%"),UnitValue(50,"%"),null,ResampleMethod.BICUBIC);

Scripting brush strokes on smart filter mask

$
0
0

Hi guys, I am a complete newbie to all this so forgive me if this is a stupid question.

 

I am having problems when trying to record brush strokes on a smart filter mask using script listener. Is this possible? Is there some trick to it?

 

Cheers,

 

Philip

Why don't my dialogs show up in Photoshop?

$
0
0

I'm running the examples from the ExtendScript Toolkit UI and the dialog examples don't do appear in photoshop. 

 

I copied SnpCreateTreeView.jsx from the examples directory to my toolkit window and ran it.  It errors out on "aNode.image = this.folderIcon;".  I assumed it was just to set icons, so I commented it out and it appeared to run without error, but it just jumps to photoshop and I see no dialog. 

 

About to run SnpCreateTreeView

Ran SnpCreateTreeView

Result: true

 

I tried a simpler example, "SnpCreateDialog.jsx" and it also didn't do anything.  It almost looks like it's going over to photoshop, loading the dialog, closing the dialog and jumping back to the toolkit.  I have managed to find some examples like "AlertBoxBuilder1.jsx" where I do see a dialog.  What's the difference here? 

Batch HDR creation script

$
0
0

I have created a Photoshop Script (using JavaScript) for batch creation of HDR images.

I have used theseprevious discussions during implementation.

 

In the beginning part of the script there are some options that you can change to customize the script's operation.

You are free to modify this script and publish your modifications.

 

The script can be found at the following URL (which is a git repository in itself) , and is also pasted below.

https://gist.github.com/1640233

 

 

// Batch Creation of HDR files
// -----------------------------------------------------------------------------------
// Opens a dialog box, asking for the container folder.
// The container folder must have separate sub folders for each of the HDR image series
// The output can be saved in a subfolder with an arbitrary name by
// changing the options below.
//
// example: to save hdr files as 
// C:\container\hdrseries1\myhdrfolder\myhdr.psd
// change the options HDROutputFolder to "myhdrfolder" 
// and option HDRFileName to "myhdr"
// 

// Extensions of source image files
var pictureExtensions = "*.jpg";
// Sub-folder to save the resulting HDR file. This folder will be created if it does not exist.
//var HDROutputFolder = "";  // disable subfolder like this
var HDROutputFolder = "HDR"
// Filename for saved HDR file. Do not set the extension here, extension is set automatically according to saveResultAsEXR option.
var HDRFileName = "HDR";
// Save EXR file (requires EXR plugin) If set to "false" saves the HDR as a  .PSD file
var saveResultAsEXR = false;
// Overwrite existing HDR output files? If set to "false" skips creating HDR files for already created image sets.
// This is useful for adding some new HDR sets into the container folder, and running the script again 
// to crate HDR files only for the newly added series.
var overwriteExistingHDR = false;
// --------------- End of settings ------------------- //

var runMergeToHDRFromScript = true;// define and set to true before including Merge To HDR.jsx
var g_ScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
var g_ScriptPath = File( g_ScriptFolderPath+'/Merge To HDR.jsx' );
$.evalFile( g_ScriptPath );

// function to manually save an EXR file. Requires EXR plugn to be installed
function saveEXR(saveFile){
    var idsave = charIDToTypeID( "save" );    var desc6 = new ActionDescriptor();    var idAs = charIDToTypeID( "As  " );    desc6.putString( idAs, "OpenEXR" );    var idIn = charIDToTypeID( "In  " );    desc6.putPath( idIn, saveFile );    executeAction( idsave, desc6, DialogModes.NO );
}

function main()
{
    var bracket_folders = [];    var selected_folder = Folder.selectDialog ("Select the container folder. The container folder should have a separate folder inside for each HDR image series.")    if (selected_folder != null)    {                                            // to process multiple container folders, uncomment following line and edit folder paths.        //bracket_folders = [ Folder('/c/images/bracket5'), Folder('/c/images/bracket9')];           bracket_folders = bracket_folders.concat(selected_folder);        for (var f = 0; f < bracket_folders.length; f++)        {            var image_folders = bracket_folders[f].getFiles();            for (var g = 0; g < image_folders.length; g++)            {                var folder = image_folders[g];                var filelist = image_folders[g].getFiles(pictureExtensions);                var photoshopHDRFolder = Folder(folder.absoluteURI + "/" + HDROutputFolder);                if (saveResultAsEXR) {                    var extension = ".exr";                } else {                    var extension = ".psd";                }                var photoshopHDRFile = File(photoshopHDRFolder.absoluteURI + "/" + HDRFileName + extension);                if (overwriteExistingHDR ==false && photoshopHDRFile.exists == true) {                    continue;                }                mergeToHDR.useAlignment = true;                mergeToHDR.outputBitDepth= 32;                mergeToHDR.mergeFilesToHDR( filelist, true, -2 );                if (photoshopHDRFolder.exists == false) {                    photoshopHDRFolder.create();                }                if (saveResultAsEXR) {                    saveEXR(photoshopHDRFile);                } else {                    activeDocument.saveAs(photoshopHDRFile );  // Use for PSD files                }                activeDocument.close(SaveOptions.DONOTSAVECHANGES);            }        }    }
}

main();

How to "change" resolution from DPI to l/cm?

$
0
0

Hi Adobe community,

 

right now I am transferring a huge and slow photoshop action to a javascript cause I needed some kind of dynamic variable an action couldn't offer. And on the other hand: a script is sooo much faster than an action. I had some points where the scripting API didn't give me enough possibilities and I had to use those annoying "action descriptors" I got from the ScriptingListener Plugin... so far so good.

 

But now I am at a point where neither the API nor action descriptors seem to help. I am trying to switch the resolution of the image from "dots per image" to "lines per cm" without really resampling it. I just want to transform the "measurement unit", for example from 304.8 DPI to 120 l/cm or from 72 DPI to 28.346 l/cm.

 

Does anyone know a way how to do this? Obviously it is possible through manual usage of the "image size" menu. And yes, I am aware of the fact that this is just cosmetic. But the client that needs this script sort of insists of the "lines per cm" measurement unit.

 

I would really appreciate any help.

 

Greetings,

Daniel

[Help needed] Sample colour in each cell of a grid

$
0
0

Hi All,

 

First of all, HAPPY OCEANS DAY!

 

Here is my problem:

 

I have hundreds of maps of exactly the same size, for which I would need to extract the "value of the colour" in each cell of each map.

There is no way I can get my hands on the GIS data, hence the need to use Photoshop.

Here is a example of these maps:

Screen Shot 2013-06-08 at 1.25.40 PM.png

 

I hope it is possible to generate a script to super-impose a grid on that map, and then get the colour in each cell. Then I'd just need to convert the colour quote into actual value, and I'm done (but there is not need to use PS for that). I did some research on the internet, but didn't find anything satisfying (I may have not used the right keywords).

 

Do you think this is a realistic option, or should I just give up right away?

 

If the answer is "yes, it might be possible", then I might also need your help to write the script

 

 

Thanks a lot for your help!

 

Fred


Copy image from clipboard to (several) x y coordinates using javascript loop

$
0
0

I have an image (551 px by 709 px) which is on the clipboard.

 

I would like this image to appear in my active document (3307 px by 4677 px)

 

The x and y locations where I want the images to appear are:

  • x  = 200      y = 800
  • x = 751       y = 800
  • x = 1340     y = 800
  • x = 1929     y = 800
  • x = 200      y = 1509

 

Can anyone help in creating a javascript loop?


  • - that uses the x and y values (to be stored in an array) and
  • - pastes/places the image in the active document at the x,y locations and
  • - the coordinates are for the left hand top of the image as beginning point.


(Everything else concerning this project is already in javascript, but I can't  work this out).

 

Help will be greatly appreciated.

 

illustration.jpg

The last line of my code that pastes the image (above) on a new layer.


   myselection.paste();

 

From there on I got stuck.

Iterate over all document layers applescript

$
0
0

Hi,I have experience as programmer but not in applescript or photoshop scritpting,

Basically I want to apply some actions to layers, but only to those layers that are named ending in '-changeMe' e.g ( 'Layer 1-changeMe', 'Background-changeMe')

 

I'm trying to convert the pseudocode below to applescript

 

foreach layer in CurrentDocument.layers

   if layer.name contains '-changeMe'

       do something

   end if

end foreach

 

In the pseudocode above I'm inveting the notation, but I hoppe you get the idea.

it's posible?

Thanks!

Creating adjustment layers without Script Listener code

$
0
0

I'm assuming it's possible to create an adjustment layer without Script Listener code, but I can't figure out how. I can create a normal layer and change it to a text layer and that seems to be about it. I was specifically trying to create a Photo Filter layer. I can do it with Script Listener code, but now I'm just curious.

 

Example:

 

adjLayer=app.activeDocument.artLayers.add().kind=LayerKind.TEXT; <--This works.

 

adjLayer=app.activeDocument.artLayers.add().kind=LayerKind.PHOTOFILTER ;  <--Does not work.

 

It allows changing to/from either a normal or text layer only. There is also a photoFilter() method which allows adjusting the values of a Photo Filter layer but only if one already exists.

 

So it appears that the add() method in the artLayers collection is only good for adding a normal or text layer. Is there any way to add an adjustment layer (other than using Script Listener code)?

 

Am I missing something simple?

cs6 Exr saving issue.

$
0
0

Hey everyone, I'm trying to update a portion of my .jsx code that worked in CS5, and now doesn't work in CS6.. EXR format is now included in CS6, and handles the alpha channel differently, basically it recognizes it now, as it didn't before as many  of you know.

 

So I am using the script listener to try and create a simple variable to pass on at save time, and I'm having problems with it saving the .exr when I try to pass the variable for the file path through... for instance, if I run this code on a file with an alpha channel, (it has to be 32 bit or it will error out):

 

function saveEXR(archiveFile) {

    var idsave = charIDToTypeID( "save" );

    var desc14 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    desc14.putString( idAs, """OpenEXR""" );

    var idIn = charIDToTypeID( "In  " );

    desc14.putPath( idIn, new File( "L:\TF_testFile\TF_testFile_red_a_v01.exr" ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc14.putInteger( idDocI, 84 );

    var idCpy = charIDToTypeID( "Cpy " );

    desc14.putBoolean( idCpy, true );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc14.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

    executeAction( idsave, desc14, DialogModes.NO );

}

saveEXR()

 

Then it works just fine, the problem is passing a dynamic path/name through the save function. So if I swap a couple lines, for instance:

 

function saveEXR(archiveFile) {  

    var idsave = charIDToTypeID( "save" );

    var desc14 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    desc14.putString( idAs, """OpenEXR""" );

    var idIn = charIDToTypeID( "In  " );

    desc14.putPath( idIn, archiveFile);

    var idDocI = charIDToTypeID( "DocI" );

    desc14.putInteger( idDocI, 84 );

    var idCpy = charIDToTypeID( "Cpy " );

    desc14.putBoolean( idCpy, true );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc14.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

    executeAction( idsave, desc14, DialogModes.YES );


}

saveEXR(archiveFile)

 

Then it doesn't work. Also, it will error saying it was unable to write the file. I checked, and it IS in fact passing the file into the correct directory and naming it properly, but it's not including the alpha channel at all. Soooooooo if anyone has any sort of clue what may be happening here, or if this sounds like a bug... I'd appreciate it. I'm stuck. :(


Artwork resizing

$
0
0

Hi All,

 

I have to resize around 600 artworks in different sizes with the following conditions

 

app.preferences.rulerUnits = Units.PICAS

 

 

Switch (case)

}

case 1 width <= 20  (No resize); break

case 2 width  >20 AND <=25 (Resize to 20); break

case 3 width  >25 AND <= 39 (No resize); break

case 4 width >39 (Resize to 39);

}

 

Any help.

 

Regards,

Vinoth

Adobe Edit in ACR stopped working.

$
0
0

Hi,

 

Can anyone help ? I have been running Russell Brown's excellent 'Adobe Edit in ACR' script for some time now through version 1.1.5 and now 1.1.6 and for some reason it has now stopped working. I have made no changes to anything that I am aware of (running Photoshop CS6 Extended) but now when I attempt to run the script I get the following script error:

 

General Photoshop error occurred. This functionality may not be available in this version of Photoshop.

The object "current document' is not currently available"

 

The script worked 100% before (both 1.1.5 and 1.1.6) - I have uninstalled and re-installed to no avail.

 

When I run Adobe Edit in ACR it creates a Raw Smart Object layer and then the error message pops up - but ACR does not open. And yes - TIFF preferences within ACR have been set as per Russell's instructions.

 

Anyone got any clues - I e-mailed Russell himself but guess he will be too busy to respond.

 

Regards,

 

Richard

A script for "Save for Web" as .jpg

$
0
0

I found a script that saves the current selected document in Photoshop as .png to the Desktop, and use it all the time.

 

function main() {

          // declare local variables

          var doc = app.activeDocument;

          var docName = app.activeDocument.name.slice(0,-4);

 

 

    var saveFile = new File("~/Desktop/" + docName + ".png");

    pngSaveOptions = new PNGSaveOptions();

    pngSaveOptions.interlaced = false;

    doc.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);

}

 

main();

 

 

Now I'd really like a similar script to do "Save for Web" as .jpg files, without a colour profile, to the Desktop. Preferably a version to save as 100% quality and one to save as 60% quality.

Any help would be greatly appreciated.


Read metadata for a file without Photoshop or Bridge

$
0
0

Hi

 

Suppose I have a file in desktop called "test.jpg". So I create this variable:

 

var myFile = new File ("~/Desktop/test.jpg");

 

This file has some keywords and instructions I need to read. And if the reading process finds the correct keyword, then it copies the file to the appropriated folder. Well, in resume, I could do everything directlly using #target estoolkit. I´d not like to involve (opening) Photoshop or Bridge.

 

Is it possible to read the metadata of a file without targetting Bridge or Photoshop? Reading the reference I did not find any method or property for this, expect for the metadata library. BUT

 

If I try to load the metadata library using:

 

if (ExternalObject.AdobeXMPScript == undefined) {

        ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

    };

 

then it sure will returns an error file or folder does not exists..

 

Any idea how I could proceed to load this library and read the metadata of a file directlly?

 

Thank you very much

 

Best Regards

Gustavo.

How to rename a Ps-path

$
0
0

I need to rename a Photoshoppath (only one path in file but with different names) with Javascript, I cannot select a pathitem and then rename. There are only two pathnames in my files: Path1 and Pad 1, but I cannot find a method to give them both the same name. And afterwards the path must be set to a clipping path but that is not the problem now. Please help me a little, thanks in advance.

How to get the color, style, stroke size and alpha values of selected object?

$
0
0

Hi All,

 

I am new to photoshop, I am facing problem regarding to get the fill color value, fill style, stroke color, stroke size and alpha value of the selected object in the photoshop using script. Is there any way to get all the property values of the selected object?

 

Any help would be appreciated.

 

Thanks...

How to get the style of a layer using photoshop scripting ??

$
0
0

As I know  there is a method  ApplyStyle(string)  which is uesd to apply the specified style to a layer. But I really don't know how to get the style name of a layer ?

Anyone who knows? Please help me!   Thank you !

Display thumbnail of PSD on ScriptUI dialog

$
0
0

I'm wanting to display a thumbnail sized jpeg or png image representation of a high resolution PSD on my ScriptUI dialog, and without having the PSD open and active. Any advice or suggestions to get me started in the right direction is much appreciated.

 

JJ

Viewing all 12244 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>