Skip to content

Commit fb3b4fe

Browse files
Add examples to PSDTools (#369)
1 parent 64e7f51 commit fb3b4fe

File tree

6 files changed

+70
-29
lines changed

6 files changed

+70
-29
lines changed

src/actions/psdTools.ts

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import ClipAction from "./psdTools/ClipAction";
2-
import GetLayerAction from "./psdTools/GetLayerAction";
3-
import SmartObjectAction from "./psdTools/SmartObjectAction";
1+
import {ClipAction} from "./psdTools/ClipAction";
2+
import {GetLayerAction} from "./psdTools/GetLayerAction";
3+
import {SmartObjectAction} from "./psdTools/SmartObjectAction";
44

55
/**
6+
* @namespace PSDTools
67
* @description Represents a layer in a Photoshop document.
7-
*
8-
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image | Deliver selected layers of a PSD image}
8+
* </br><b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image | Deliver selected layers of a PSD image}
99
* @memberOf Actions
10-
* @namespace PSDTools
10+
* @example
11+
* // See examples under each method
1112
*/
1213

1314

@@ -16,6 +17,19 @@ import SmartObjectAction from "./psdTools/SmartObjectAction";
1617
* @description Trims the pixels of a PSD image according to a Photoshop clipping path that is stored in the image's metadata.
1718
* @memberOf Actions.PSDTools
1819
* @return {Actions.PSDTools.ClipAction}
20+
* @example
21+
* import {Cloudinary} from '@cloudinary/base/instance/Cloudinary';
22+
* import {clip} from '@cloudinary/base/actions/psdTools';
23+
*
24+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
25+
* const image = yourCldInstance.image('woman');
26+
*
27+
* image.psdTools(
28+
* clip()
29+
* .byName('foo') // either name, or number
30+
* .byNumber(2) // either name, or number
31+
* .evenOdd() // Use the evenodd clipping rule
32+
* );
1933
*/
2034
function clip(): ClipAction {
2135
return new ClipAction();
@@ -28,6 +42,19 @@ function clip(): ClipAction {
2842
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image | Deliver selected layers of a PSD image}
2943
* @memberOf Actions.PSDTools
3044
* @return {Actions.PSDTools.GetLayerAction}
45+
* @example
46+
* import {Cloudinary} from '@cloudinary/base/instance/Cloudinary';
47+
* import {getLayer} from '@cloudinary/base/actions/psdTools';
48+
*
49+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
50+
* const image = yourCldInstance.image('woman');
51+
*
52+
* image.psdTools(
53+
* getLayer()
54+
* .byName('foo') // One of the three
55+
* .byIndex(2) // One of the three
56+
* .byRange(1, 3) // One of the three
57+
* );
3158
*/
3259
function getLayer(): GetLayerAction {
3360
return new GetLayerAction();
@@ -38,6 +65,18 @@ function getLayer(): GetLayerAction {
3865
* @description Extracts the original content of an embedded object of a Photoshop image.
3966
* @memberOf Actions.PSDTools
4067
* @return {Actions.PSDTools.SmartObjectAction}
68+
* @example
69+
* import {Cloudinary} from '@cloudinary/base/instance/Cloudinary';
70+
* import {smartObject} from '@cloudinary/base/actions/psdTools';
71+
*
72+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
73+
* const image = yourCldInstance.image('woman');
74+
*
75+
* image.psdTools(
76+
* smartObject()
77+
* .byLayerName('foo') // either name, or number
78+
* .byIndex(2) // either name, or number
79+
* );
4180
*/
4281
function smartObject(): SmartObjectAction {
4382
return new SmartObjectAction();

src/actions/psdTools/ClipAction.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import {clip, clipEvenOdd} from "../../qualifiers/flag";
55

66
/**
77
* @description Defines the clipping path to use when trimming pixels.
8-
* @memberOf Actions.PSDTools
98
* @extends {SDK.Action}
9+
* @memberOf Actions.PSDTools
10+
* @see Visit {@link Actions.PSDTools| PSDTools} for an example
1011
*/
1112
class ClipAction extends Action {
1213
private path: string | number;
@@ -64,4 +65,4 @@ class ClipAction extends Action {
6465
}
6566
}
6667

67-
export default ClipAction;
68+
export {ClipAction};

src/actions/psdTools/GetLayerAction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {QualifierValue} from "../../internal/qualifier/QualifierValue";
44

55
/**
66
* @description Represents a layer in a Photoshop document.
7-
*
8-
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image | Deliver selected layers of a PSD image}
9-
* @memberOf Actions.PSDTools
7+
* </br><b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#deliver_selected_layers_of_a_psd_image | Deliver selected layers of a PSD image}
108
* @extends {SDK.Action}
9+
* @memberOf Actions.PSDTools
10+
* @see Visit {@link Actions.PSDTools| PSDTools} for an example
1111
*/
1212
class GetLayerAction extends Action {
1313
private name: string;
@@ -20,7 +20,7 @@ class GetLayerAction extends Action {
2020

2121
/**
2222
* @description deliver an image containing only specified layer of a Photoshop image from The layer index
23-
* @param {string|number} the index of the layer
23+
* @param {string|number} from the index of the layer
2424
*/
2525
byIndex(from: string|number): this{
2626
this.qualifierValue.addValue(from);
@@ -62,4 +62,4 @@ class GetLayerAction extends Action {
6262
}
6363
}
6464

65-
export default GetLayerAction;
65+
export {GetLayerAction};

src/actions/psdTools/SmartObjectAction.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {QualifierValue} from "../../internal/qualifier/QualifierValue";
44

55
/**
66
* @description Represents an embedded smart object in a Photoshop document.
7-
*
8-
* <b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#extract_the_original_content_of_an_embedded_object
9-
* | Extract the original content of an embedded Photoshop object}
10-
* @memberOf Actions.PSDTools
7+
* </br><b>Learn more:</b> {@link https://cloudinary.com/documentation/paged_and_layered_media#extract_the_original_content_of_an_embedded_object | Extract the original content of an embedded Photoshop object}
118
* @extends {SDK.Action}
9+
* @memberOf Actions.PSDTools
10+
* @see Visit {@link Actions.PSDTools| PSDTools} for an example
1211
*/
13-
class SmartObjectAction extends Action{
14-
private smartObjectValue: string|number;
12+
class SmartObjectAction extends Action {
13+
private smartObjectValue: string | number;
1514
private qualifierValue = new QualifierValue();
1615
private useName = false;
16+
1717
constructor() {
1818
super();
1919
this.qualifierValue.delimiter = ';';
@@ -23,7 +23,7 @@ class SmartObjectAction extends Action{
2323
* @description Creates a new instance using the specified number.
2424
* @param index The number.
2525
*/
26-
byIndex(index: string|number): this{
26+
byIndex(index: string | number): this {
2727
this.smartObjectValue = index;
2828
this.qualifierValue.addValue(index);
2929
return this;
@@ -33,13 +33,13 @@ class SmartObjectAction extends Action{
3333
* @description Creates an instance using the name.
3434
* @param {string} layerName The name of the layer
3535
*/
36-
byLayerName(layerName: string): this{
36+
byLayerName(layerName: string): this {
3737
this.useName = true;
3838
this.qualifierValue.addValue(layerName);
3939
return this;
4040
}
4141

42-
protected prepareQualifiers() : void {
42+
protected prepareQualifiers(): void {
4343
let qualifierValue;
4444
if (this.useName) {
4545
qualifierValue = new QualifierValue(['embedded:name', this.qualifierValue]);
@@ -51,4 +51,4 @@ class SmartObjectAction extends Action{
5151
}
5252
}
5353

54-
export default SmartObjectAction;
54+
export {SmartObjectAction};

src/assets/CloudinaryTransformable.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import {Action} from "../internal/Action";
99
import RotateAction from "../actions/rotate/RotateAction";
1010
import {NamedTransformationAction} from "../actions/namedTransformation/NamedTransformationAction";
1111
import {SystemColors} from "../qualifiers/color";
12-
import SmartObjectAction from "../actions/psdTools/SmartObjectAction";
13-
import ClipAction from "../actions/psdTools/ClipAction";
14-
import GetLayerAction from "../actions/psdTools/GetLayerAction";
1512
import {ExtractAction} from "../actions/extract";
13+
import {SmartObjectAction} from "../actions/psdTools/SmartObjectAction";
14+
import {ClipAction} from "../actions/psdTools/ClipAction";
15+
import {GetLayerAction} from "../actions/psdTools/GetLayerAction";
16+
import {Extract} from "../actions/extract";
1617
import {FlagQualifier} from "../qualifiers/flag/FlagQualifier";
1718
import CustomFunctionAction from "../actions/customFunction/CustomFunctionAction";
1819
import {EffectActions} from "../actions/effect";

src/transformation/Transformation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import ResizeSimpleAction from "../actions/resize/ResizeSimpleAction";
88
import RotateAction from "../actions/rotate/RotateAction";
99
import {BackgroundColor} from "../actions/background/actions/BackgroundColor";
1010
import {NamedTransformationAction} from "../actions/namedTransformation/NamedTransformationAction";
11-
import SmartObjectAction from "../actions/psdTools/SmartObjectAction";
12-
import ClipAction from "../actions/psdTools/ClipAction";
13-
import GetLayerAction from "../actions/psdTools/GetLayerAction";
11+
import {SmartObjectAction} from "../actions/psdTools/SmartObjectAction";
12+
import {ClipAction} from "../actions/psdTools/ClipAction";
13+
import {GetLayerAction} from "../actions/psdTools/GetLayerAction";
1414
import {IReshape} from "../actions/reshape";
1515
import {SystemColors} from "../qualifiers/color";
1616
import {prepareColor} from "../internal/utils/prepareColor";

0 commit comments

Comments
 (0)