Skip to content

Commit

Permalink
Ps applyImage and calculations (#417)
Browse files Browse the repository at this point in the history
* Remove object from default value column.

* Add applyImage and calculations methods.

Rename compositeChannels to componentChannels, correcting other usages of composite, as well.
Moved Constants up in left nav to be closer to their usage.
Orphaned interface pages are parsed and populated under Objects.
Deprecated-tagged items will be styled with strikethrough.

* Fix constants reference.

Add variable definintions to code example.

* Update yarn.lock

Add May to current Beta.
  • Loading branch information
samgannawayA committed Apr 27, 2023
1 parent c3d9e18 commit 9d2834c
Show file tree
Hide file tree
Showing 21 changed files with 21,603 additions and 15,537 deletions.
80 changes: 48 additions & 32 deletions reference-ps.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,32 @@ module.exports = [{
"path": "/ps_reference/classes/pathitem/"
},
{
"title": "PathPoint",
"path": "/ps_reference/classes/pathpoint/"
"title": "PathItems",
"path": "/ps_reference/classes/pathitems/"
},
{
"title": "SubPathItem",
"path": "/ps_reference/classes/subpathitem/"
"title": "PathPoint",
"path": "/ps_reference/classes/pathpoint/"
},
{
"title": "PathItems",
"path": "/ps_reference/classes/pathitems/"
"title": "PathPointInfo",
"path": "/ps_reference/classes/pathpointinfo/"
},
{
"title": "PathPoints",
"path": "/ps_reference/classes/pathpoints/"
},
{
"title": "SubPathItems",
"path": "/ps_reference/classes/subpathitems/"
"title": "SubPathInfo",
"path": "/ps_reference/classes/subpathinfo/"
},
{
"title": "PathPointInfo",
"path": "/ps_reference/classes/pathpointinfo/"
"title": "SubPathItem",
"path": "/ps_reference/classes/subpathitem/"
},
{
"title": "SubPathInfo",
"path": "/ps_reference/classes/subpathinfo/"
"title": "SubPathItems",
"path": "/ps_reference/classes/subpathitems/"
}
]
},
Expand Down Expand Up @@ -183,24 +183,24 @@ module.exports = [{
"header": true,
"pages": [
{
"title": "TextItem",
"path": "/ps_reference/classes/textitem/"
"title": "CharacterStyle",
"path": "/ps_reference/classes/characterstyle/"
},
{
"title": "TextFonts",
"path": "/ps_reference/classes/textfonts/"
"title": "ParagraphStyle",
"path": "/ps_reference/classes/paragraphstyle/"
},
{
"title": "TextFont",
"path": "/ps_reference/classes/textfont/"
},
{
"title": "CharacterStyle",
"path": "/ps_reference/classes/characterstyle/"
"title": "TextFonts",
"path": "/ps_reference/classes/textfonts/"
},
{
"title": "ParagraphStyle",
"path": "/ps_reference/classes/paragraphstyle/"
"title": "TextItem",
"path": "/ps_reference/classes/textitem/"
},
{
"title": "WarpStyle",
Expand Down Expand Up @@ -289,14 +289,14 @@ module.exports = [{
"title": "Document Create Options",
"path": "/ps_reference/objects/createoptions/documentcreateoptions/"
},
{
"title": "Layer Comp Create Options",
"path": "/ps_reference/objects/createoptions/layercompcreateoptions/"
},
{
"title": "Group Layer Create Options",
"path": "/ps_reference/objects/createoptions/grouplayercreateoptions/"
},
{
"title": "Layer Comp Create Options",
"path": "/ps_reference/objects/createoptions/layercompcreateoptions/"
},
{
"title": "Pixel Layer Create Options",
"path": "/ps_reference/objects/createoptions/pixellayercreateoptions/"
Expand All @@ -313,12 +313,24 @@ module.exports = [{
"header": true,
"pages": [
{
"title": "Color Picker Option",
"path": "/ps_reference/objects/options/colorpickeroption/"
"title": "Apply Image Options",
"path": "/ps_reference/objects/options/applyimageoptions/"
},
{
"title": "Layer Comp Recapture Options",
"path": "/ps_reference/objects/options/layercomprecaptureoptions/"
"title": "Apply Image Source",
"path": "/ps_reference/objects/options/applyimagesource/"
},
{
"title": "Calculations Options",
"path": "/ps_reference/objects/options/calculationsoptions/"
},
{
"title": "Calculations Source",
"path": "/ps_reference/objects/options/calculationssource/"
},
{
"title": "Color Picker Option",
"path": "/ps_reference/objects/options/colorpickeroption/"
},
{
"title": "Hyphenation Properties",
Expand All @@ -327,6 +339,10 @@ module.exports = [{
{
"title": "Justification Properties",
"path": "/ps_reference/objects/options/justificationproperties/"
},
{
"title": "Layer Comp Recapture Options",
"path": "/ps_reference/objects/options/layercomprecaptureoptions/"
}
]
},
Expand Down Expand Up @@ -392,6 +408,10 @@ module.exports = [{
"path": "/ps_reference/colors/rgbcolor/"
}
]
},{
"title": "Constants",
"header": true,
"path": "/ps_reference/modules/constants/"
},{
"title": "Advanced",
"path": "/ps_reference/media/",
Expand Down Expand Up @@ -429,10 +449,6 @@ module.exports = [{
"path": "/ps_reference/media/cpp-pluginsdk/"
}
]
},{
"title": "Constants",
"header": true,
"path": "/ps_reference/modules/constants/"
},{
"title": "UXP Scripting",
"header": true,
Expand Down
19 changes: 16 additions & 3 deletions src/pages/ps_reference/changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ description: Contains a running log of changes to the UXP API environment in Ado

# Photoshop API Changelog

## Photoshop Beta 24.4 (April 2023)
## Photoshop Beta 24.5 (April/May 2023)
### Calculations and Apply Image
The blending operations [Layer](../classes/layer) Apply Image and [Document](../classes/document) Calculations are now available.

- [`applyImage()`](classes/layer/#applyimage)
- [`calculations()`](classes/document/#calculations)

Both methods accept an options object that matches the parameters required in the respective UI dialog.

### Other updates
- Replaced `compositeChannels` property on Document with more appropriately named `componentChannels`.
- Channels returned will be of type `ComponentChannel` instead of `CompositeChannel` with corresponding `typename`.

## Photoshop 24.4 (April 2023)
### Imaging API update
The [Imaging API](../media/imaging) is moving out of Prerelease. It will now be available in the Beta build with the module name "imaging".
Previously, access was via `require("photoshop").imaging_beta`. It is now `require("photoshop").imaging`.
Expand Down Expand Up @@ -174,7 +187,7 @@ The CountItems DOM API is now available in Photoshop.

#### We now throw errors in more situations with layer blend modes

- Passing a value that is not in [[Constants.blendMode]].
- Passing a value that is not in [Constants.blendMode](../modules/constants/#blendmode).
- Passing a blend mode that is not compatible with the document's color mode or bit depth. Previously, this call would fail silently.
- Attempting to set the blend mode on the Background layer. Previously, doing so would convert Background to a regular layer and generate a new layer ID. Automatic Background promotion is undesirable as a side effect in this case. This action is not available via the UI.

Expand Down Expand Up @@ -471,7 +484,7 @@ To roll back to the MAX 2020 version of the Photoshop DOM API, set the `apiVersi
- `saveAs` is provided for `bmp`, `gif`, `jpg`, `png`, `psb`, `psd` formats. Use SaveOptions objects to request specific saves (e.g. [PhotoshopSaveOptions](../objects/photoshopsaveoptions/)).
- [layer.id getter](../classes/layer)
- Updated [document.createLayer](../classes/document/#createlayer) and [document.createLayerGroup](../classes/document/#createlayergroup)
- With respective Create options: [LayerCreateOptions](../objects/createoptions/layercreateoptions/) and [GroupLayerCreateOptions](../objects/createoptions/grouplayercreateoptions).
- With respective Create options: LayerCreateOptions and GroupLayerCreateOptions.
- Collection access updates for Layer and Layer-like items are planned for upcoming releases.

#### Photoshop Core updates
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ps_reference/classes/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Represents a channel in a Photoshop document.
You can access instances of channels using one of these methods:

```javascript
// An array of composite channels in the document
const compositeChannels = app.activeDocument.compositeChannels
// An array of component channels in the document
const componentChannels = app.activeDocument.componentChannels

// An array of active (selected) channels in the document
const activeChannels = app.activeDocument.activeChannels
Expand Down
18 changes: 9 additions & 9 deletions src/pages/ps_reference/classes/characterstyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ The Class that stores properties related to the Character panel in the Photoshop
| Name | Type | Access | Default | Range | Min Version | Description |
| :------ | :------ | :------ | :------ | :------ | :------ | :------ |
| alternateLigatures | *boolean* | R W | false | - | 24.1 | Discretionary ligatures. |
| antiAliasMethod | [*AntiAlias*](/ps_reference/modules/constants/#antialias) | R W | AntiAlias.SHARP | - | 24.1 | The text anti-aliasing |
| autoKerning | [*AutoKernType*](/ps_reference/modules/constants/#autokerntype) | R W | AutoKernType.METRICS | - | 24.1 | The auto kerning option to use. |
| baseline | [*Baseline*](/ps_reference/modules/constants/#baseline) | R W | Baseline.NORMAL | - | 24.1 | The text baseline. |
| antiAliasMethod | [*AntiAlias*](/ps_reference/modules/constants/#antialias) | R W | SHARP | - | 24.1 | The text anti-aliasing |
| autoKerning | [*AutoKernType*](/ps_reference/modules/constants/#autokerntype) | R W | METRICS | - | 24.1 | The auto kerning option to use. |
| baseline | [*Baseline*](/ps_reference/modules/constants/#baseline) | R W | NORMAL | - | 24.1 | The text baseline. |
| baselineShift | *number* | R W | - | -1296..1296 | 24.1 | The value in pixels to use in the baseline offset of text for a 72ppi document. |
| capitalization | [*TextCase*](/ps_reference/modules/constants/#textcase) | R W | TextCase.NORMAL | - | 24.1 | The text case. |
| characterAlignment | [*CharacterAlignment*](/ps_reference/modules/constants/#characteralignment) | R W | CharacterAlignment.ROMAN | - | 24.1 | Character alignment. When a line of text contains different sizes of characters, you can specify how to align text to the largest characters in the line. |
| capitalization | [*TextCase*](/ps_reference/modules/constants/#textcase) | R W | NORMAL | - | 24.1 | The text case. |
| characterAlignment | [*CharacterAlignment*](/ps_reference/modules/constants/#characteralignment) | R W | ROMAN | - | 24.1 | Character alignment. When a line of text contains different sizes of characters, you can specify how to align text to the largest characters in the line. |
| color | [*SolidColor*](/ps_reference/classes/solidcolor/) | R W | - | - | 24.1 | The text color as a [SolidColor](/ps_reference/classes/solidcolor/) instance. |
| fauxBold | *boolean* | R W | false | - | 24.1 | True to use Faux Bold. Setting this to true is equivalent to selecting text and clicking Faux Bold in the Character panel. |
| fauxItalic | *boolean* | R W | false | - | 24.1 | True to use Faux Italic. Setting this to true is equivalent to selecting text and clicking Faux Italic in the Character panel. |
Expand All @@ -43,17 +43,17 @@ The Class that stores properties related to the Character panel in the Photoshop
| language | [*Language*](/ps_reference/modules/constants/#language) | R W | - | - | 24.1 | Language used as a basis for hyphenation rules and spelling. |
| leading | *number* | R W | null | 0..4999.99 | 24.1 | The leading amount in pixels for a 72ppi document. |
| ligatures | *boolean* | R W | true | - | 24.1 | Standard ligatures (default: true). |
| middleEasternDigitsType | [*MiddleEasternDigitsType*](/ps_reference/modules/constants/#middleeasterndigitstype) | R W | MiddleEasternDigitsType.LTRARABIC | - | 24.1 | The text digits type to use (Middle Eastern features) |
| middleEasternTextDirection | [*MiddleEasternTextDirection*](/ps_reference/modules/constants/#middleeasterntextdirection) | R W | MiddleEasternTextDirection.DEFAULT | - | 24.1 | The text direction (Middle Eastern features) |
| middleEasternDigitsType | [*MiddleEasternDigitsType*](/ps_reference/modules/constants/#middleeasterndigitstype) | R W | LTRARABIC | - | 24.1 | The text digits type to use (Middle Eastern features) |
| middleEasternTextDirection | [*MiddleEasternTextDirection*](/ps_reference/modules/constants/#middleeasterntextdirection) | R W | DEFAULT | - | 24.1 | The text direction (Middle Eastern features) |
| noBreak | *boolean* | R W | false | - | 24.1 | True to disallow line breaks in this text. |
| ordinals | *boolean* | R W | false | - | 24.1 | Ordinals. |
| size | *number* | R W | - | 0.01..1296 | 24.1 | The font size in pixels for a 72ppi document. |
| strikeThrough | [*StrikeThrough*](/ps_reference/modules/constants/#strikethrough) | R W | StrikeThrough.STRIKEOFF | - | 24.1 | Whether the text is strikethrough or not. |
| strikeThrough | [*StrikeThrough*](/ps_reference/modules/constants/#strikethrough) | R W | STRIKEOFF | - | 24.1 | Whether the text is strikethrough or not. |
| stylisticAlternates | *boolean* | R W | false | - | 24.1 | Stylistic Alternates |
| swash | *boolean* | R W | false | - | 24.1 | Swash. |
| titlingAlternates | *boolean* | R W | false | - | 24.1 | Titling alternates. |
| tracking | *number* | R W | - | -1000..1000 | 24.1 | The amount of uniform spacing between multiple characters. Tracking units are 1/1000 of an em space. The width of an em space is relative to the current type size. In a 1-point font, 1 em equals 1 point; in a 10-point font, 1 em equals 10 points. So for example, 100 tracking units in a 10-point font are equivalent to 1 point |
| underline | [*Underline*](/ps_reference/modules/constants/#underline) | R W | Underline.NONE | - | 24.1 | The underline style to use. |
| underline | [*Underline*](/ps_reference/modules/constants/#underline) | R W | NONE | - | 24.1 | The underline style to use. |
| useAutoLeading | *boolean* | R W | - | - | 24.1 | True to use a font's built-in leading information. |
| verticalDiacriticPosition | *number* | R W | - | -1000..1000 | 24.1 | Adjust the vertical diacritic position for Middle Eastern languages. |
| verticalScale | *number* | R W | - | 0..1000 | 24.1 | Character scaling (vertical) in proportion to horizontalScale, as a percentage value. |
Expand Down
64 changes: 56 additions & 8 deletions src/pages/ps_reference/classes/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ Represents a single Photoshop document that is currently open
You can access instances of documents using one of these methods:

```javascript
const app = require('photoshop').app;
const constants = require('photoshop').constants;

// The currently active document from the Photoshop object
const currentDocument = app.activeDocument
const currentDocument = app.activeDocument;

// Choose one of the open documents from the Photoshop object
const secondDocument = app.documents[1]
const secondDocument = app.documents[1];

// You can also create an instance of a document via a UXP File entry
let fileEntry = require('uxp').storage.localFileSystem.getFileForOpening()
const newDocument = await app.open('/project.psd')
let fileEntry = require('uxp').storage.localFileSystem.getFileForOpening();
const newDocument = await app.open('/project.psd');
```

## Properties
Expand Down Expand Up @@ -83,11 +86,12 @@ document.saveAs.psb(entryPsb, { embedColorProfile: true });
| colorProfileName | *string* | R W | 23.0 | Name of the color profile. Valid only when [colorProfileType](/ps_reference/classes/document/#colorprofiletype) is `CUSTOM` or `WORKING`, returns "None" otherwise. |
| colorProfileType | [*ColorProfileType*](/ps_reference/modules/constants/#colorprofiletype) | R W | 23.0 | Whether the document uses the working color profile, a custom profile, or no profile. |
| colorSamplers | [*ColorSamplers*](/ps_reference/classes/colorsamplers/) | R | 24.0 | The collection of ColorSamplers present in the document. |
| compositeChannels | [*Channel*](/ps_reference/classes/channel/)[] | R | 23.0 | Composite channels in the document. |
| componentChannels | [*Channel*](/ps_reference/classes/channel/)[] | R | 24.5 | Component channels in the document. |
| ~~compositeChannels~~ | [*Channel*](/ps_reference/classes/channel/)[] | R | 23.0 | Deprecated since these channels are component not composite. Use `compositeChannels` above. |
| countItems | [*CountItems*](/ps_reference/classes/countitems/) | R | 24.1 | The collection of CountItems present in the document. |
| guides | [*Guides*](/ps_reference/classes/guides/) | R | 23.0 | The collection of Guides present in the document. |
| height | *number* | R | 22.5 | Document's height in pixels. |
| histogram | *number*[] | R | 23.0 | A histogram containing the number of pixels at each color intensity level for the composite channel. The array contains 256 members. Valid only when [mode](/ps_reference/classes/document/#mode) = `DocumentMode.{RGB,CMYK,INDEXEDCOLOR}` |
| histogram | *number*[] | R | 23.0 | A histogram containing the number of pixels at each color intensity level for the component channel. The array contains 256 members. Valid only when [mode](/ps_reference/classes/document/#mode) = `DocumentMode.{RGB,CMYK,INDEXEDCOLOR}` |
| historyStates | [*HistoryStates*](/ps_reference/classes/historystates/) | R | 22.5 | History states of the document. |
| id | *number* | R | 22.5 | The internal ID of this document will remain valid as long as this document is open. It can be used for batchPlay calls to refer to this document. |
| layerComps | [*LayerComps*](/ps_reference/classes/layercomps/) | R | 24.0 | The layer comps present in the document. |
Expand All @@ -106,6 +110,50 @@ document.saveAs.psb(entryPsb, { embedColorProfile: true });

## Methods

### calculations
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.5</span>

**async** : *Promise*<void \| [*Channel*](/ps_reference/classes/channel/) \| [*Document*](/ps_reference/classes/document/)\>

The Calculations command lets you blend two individual channels from one or more source images. You can then
apply the results to a new image or to a new channel or selection in the active image.

Performs Image > Calculations on the document. See the [CalculationsOptions](/ps_reference/objects/options/calculationsoptions/)
object for more info and examples.

```javascript
const doc = app.activeDocument;
const options = {
source1: {
document: doc,
layer: doc.layers[0],
channel: CalculationsChannel.GRAY
invert: true
},
source2: {
document: doc,
layer: CalculationsLayer.MERGED,
channel: doc.channels[2]
},
blending: CalculationsBlendMode.DARKEN,
opacity: 50,
result: CalculationsResult.NEWCHANNEL
};
doc.calculations(options);

```

Known issue: currently calculations requires having exactly one unlocked pixel layer being selected otherwise
it won't work. In future there should not be any layer requirements since this cannot output into layer.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `calculationsOptions` | [*CalculationsOptions*](/ps_reference/objects/options/calculationsoptions/) | Option object for the calculations. |

___

### changeMode
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">23.0</span>

Expand Down Expand Up @@ -188,7 +236,7 @@ Create a new pixel layer.
```javascript
await doc.createLayer(
Constants.LayerKind.NORMAL,
{ name: "myLayer", opacity: 80, blendMode: Constants.BlendMode.COLORDODGE })
{ name: "myLayer", opacity: 80, blendMode: constants.BlendMode.COLORDODGE })
```

#### Parameters
Expand All @@ -203,7 +251,7 @@ await doc.createLayer(
Create a new layer group.

```javascript
await doc.createLayer( Constants.LayerKind.GROUP, { name: "myLayer", opacity: 80 })
await doc.createLayer( constants.LayerKind.GROUP, { name: "myLayer", opacity: 80 })
```

#### Parameters
Expand Down
18 changes: 18 additions & 0 deletions src/pages/ps_reference/classes/layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,24 @@ Unsupported color modes: Indexed Color, Bitmap

___

### applyImage
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">24.5</span>

**async** : *Promise*<void\>

The applyImage method lets you blend one image’s layer and channel (the source) with a this layer (the target).
This will change pixels contained in this layer.
Performs Image > Apply Image on the document. See the ApplyImageOptions
object for more info and examples.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `applyImageOptions` | [*ApplyImageOptions*](/ps_reference/objects/options/applyimageoptions/) | Option object for applyImage. |

___

### applyLensBlur
<span class="minversion" style="display: block; margin-bottom: -1em; margin-left: 36em; float:left; opacity:0.5;">23.5</span>

Expand Down
Loading

0 comments on commit 9d2834c

Please sign in to comment.