Adjust exposure of an ArtLayer

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

ruudw
Posts: 1
Joined: Fri Oct 19, 2018 11:05 am

Adjust exposure of an ArtLayer

Postby ruudw » Fri Oct 19, 2018 12:08 pm

I am trying to adjust exposure of a newly created ArtLayer. I have tried three different approaches, but none really worked (see below). How should I do this?

What I have tried:
  1. Change exposure using a method on the ArtLayer. I thought to try adjustExposure, like adjustLevels. But such a function does not exist according to the documentation (and indeed raises an exception.

    Code: Select all

    docRef.activeLayer.adjustExposure(1, 0, 1);
  2. I tried creating an ArtLayer and change the kind to LayerKind.EXPOSURE. This raises an exception saying I'm only allowed to change type of an ArtLayer to text or normal
  3. Finally I tried duplicating an existing ArtLayer of kind exposure from an another document. Drawback would be I'd always require this file to be opened. But this has some weird effects because I'm looping through 3 channels and copy a layer 3 times. The script doesn't select the layers that I think it should, probably some reference problem. I've added this code below as a reference.

Code of my thrid option, that has weird effects:

Code: Select all

var adjustmentLayersRef = app.documents.getByName('adjustmentlayers.psd');
var docRef = app.activeDocument;

// Select last two channels
for (var i = 0; i < 2; i++) {
var layerRef = docRef.artLayers.add();
docRef.activeLayer = layerRef;

// Must activate source to copy layers from there
app.activeDocument = adjustmentLayersRef;

// Copy exposure layer
var adjustmentLayer = adjustmentLayersRef.layers[0].duplicate(docRef.activeLayer, ElementPlacement.PLACEBEFORE);
app.activeDocument = docRef;

adjustmentLayer.name = layerRef.name + ' adjustment ' + i;
adjustmentLayer.grouped = true;

// Restore the document we where editing
app.activeDocument = docRef;
}

Screenshots of what happens below:
Incorrect: When layer[0] is of kind "exposure" eveything goes wrong. No error messages, but the layers aren't copied to the target file and the rest of the process goes wrong...
Correct: When layer[0] is of kind "brightness" everything looks fine; target file receives two adjustment layers, each grouped above a single new layer.
copy-layers.png
copy-layers.png (95.93 KiB) Viewed 3878 times

Return to “Help Me”

Who is online

Users browsing this forum: No registered users and 10 guests