Edit text
The Edit Text endpoint allows you to modify text layers within Photoshop files (PSD files).
In these example images, we've altered the font on the original image (on the left) using the Text API:
The Edit Text endpoint supports editing one or more text layers within a PSD. Users can:
data-slots=text1, text2
data-repeat=5
data-iconColor=#2ac3a2
data-icon=checkmark
data-variant=fullWidth
Known limitations
- The API can't automatically detect missing fonts in the layers. To prevent potentially missing fonts from being replaced, provide an
hrefto the font inoptions.fonts. For more details on specifying custom fonts, see the Font handling section. - Ensure that the input file is a PSD and that it contains one or more text layers.
- Some text attributes (for example, tracking, leading, and kerning) don't retain their original values.
Font handling
To correctly operate on text layers, the fonts needed for those layers need to be available when processing the PSD.
Reference fonts in the API request using the correct Postscript name for that font. Using any other name causes the API to treat this as a missing font.
To use a custom font you must include an href to the font in the API request inputs, in this format: <font_postscript_name>.<ext>.
Example
{
"storage": "external",
"href": "<STORAGE_URL_TO_OPEN_SANS_CONDENSED_LIGHT_TTF>"
}
Handling missing fonts
Use the manageMissingFonts field in the options of the request to specify how to handle missing fonts. There are two accepted values:
failto force the request/job to fail.useDefaultto use the system designated default font:ArialMT.
Or specify a global font in the globalFont field in the options section of the request, which would act as a default font for the current request.
data-variant=info
data-slots=heading, text1
href and storage type in the options.fonts section of the request.Supported fonts
The supported Postscript fonts are:
Implementation examples
Making a text layer edit
This code sample makes a text layer edit:
curl -X POST \
https://image.adobe.io/pie/psdService/text \
-H "Authorization: Bearer $token" \
-H "x-api-key: $apiKey" \
-H "Content-Type: application/json" \
-d '{
"inputs":[
{
"href":"<SIGNED_GET_URL>",
"storage":"<storage>"
}
],
"options":{
"layers":[
{
"name": "My Text Layer",
"text": {
"content": "CHANGED TO NEW TEXT",
"orientation": "horizontal",
"characterStyles": [{
"size": 15,
"orientation": "horizontal",
"color": {
"red":255,
"green":0,
"blue":0
}
}],
"paragraphStyles": [{
"alignment": "right"
}]
}
}
]
},
"outputs":[
{
"href":"<SIGNED_POST_URL>",
"storage":"<storage>",
"type":"vnd.adobe.photoshop"
}
]
}'
Editing two text layers
This example applies edits to two text layers:
curl -X POST \
https://image.adobe.io/pie/psdService/text \
-H "Authorization: Bearer $token" \
-H "x-api-key: $apiKey" \
-H "Content-Type: application/json" \
-d '{
"inputs": [
{
"href": "<SIGNED_GET_URL>",
"storage": "<storage>"
}
],
"options": {
"fonts": [
{
"storage": "<storage>",
"href": "<SIGNED_GET_URL>"
}
],
"layers": [
{
"name": "<name_of_text_layer_1_to_edit>",
"text": {
"orientation": "horizontal",
"contents": "New text Contents 1",
"antiAlias": "antiAliasSharp",
"characterStyles": [{
"autoKern": "metricsKern",
"fontPostScriptName": "<font_postscript_name>",
"fontCaps": "allCaps",
"size": 25,
"leading": 20,
"tracking": 20,
"syntheticBold": true,
"ligature": true,
"syntheticItalic": true,
"color": {
"blue": 100,
"green": 200,
"red": 163
}
}],
"paragraphStyles": [{
"align": "right"
}]
}
},
{
"name": "<name_of_text_layer_2_to_edit>",
"text": {
"contents": "New text Contents 2",
"characterStyles": [{
"size": 45,
"stylisticAlternates": true,
"leading": 100,
"tracking": 100,
"baseline": "subScript",
"strikethrough": true,
"underline": true,
"verticalScale": 150,
"horizontalScale": 200,
"color": {
"blue": 300,
"green": 100,
"red": 63
}
}]
}
}
]
},
"outputs": [
{
"href": "<SIGNED_POST_URL>",
"type": "vnd.adobe.photoshop",
"storage": "<storage>"
}
]
}'
Changing the font in a text layer
This example changes the font in a text layer named My Text Layer to a custom font VeganStylePersonalUse. The value for the fontName field in the text.characterStyles section is the full Postscript name of the custom font:
curl -X POST \
https://image.adobe.io/pie/psdService/text \
-H "Authorization: Bearer $token" \
-H "x-api-key: $apiKey" \
-H "Content-Type: application/json" \
-d '{
"inputs":[
{
"href":"<SIGNED_GET_URL>",
"storage":"<storage>"
}
],
"options":{
"fonts": [
{
"storage": "<storage>",
"href": "<SIGNED_GET_URL_TO_VeganStylePersonalUse.ttf>"
}
],
"layers":[
{
"name": "My Text Layer",
"text": {
"content": "CHANGED TO NEW TEXT",
"orientation": "horizontal",
"characterStyles": [{
"size": 15,
"orientation": "horizontal",
"color": {
"red":255,
"green":0,
"blue":0
}
}],
"paragraphStyles": [{
"alignment": "right"
}]
}
}
]
},
"outputs":[
{
"href":"<SIGNED_POST_URL>",
"storage":"<storage>",
"type":"vnd.adobe.photoshop"
}
]
}'