adobedocs / cis-photoshop-api-docs Goto Github PK
View Code? Open in Web Editor NEWhttps://developer.adobe.com/photoshop/photoshop-api-docs/
Home Page: https://developer.adobe.com/photoshop/photoshop-api-docs/
License: Apache License 2.0
https://developer.adobe.com/photoshop/photoshop-api-docs/
Home Page: https://developer.adobe.com/photoshop/photoshop-api-docs/
License: Apache License 2.0
I try to use text api to change the text type to point, but the output file is also keep input text type.
change the text type by text api
can't change the text type
{ "inputs": [ { "href": "input_url", "storage": "external" } ], "options": { "layers": [ { "id": 8, "text": { "paragraphStyles": [{"spaceBefore": 0, "spaceAfter": 0}], “textType": "point", "characterStyles": [{"fontPostScriptName": "SourceHanSerif-Heavy"}], }, }, { "id": 9, "text": { "paragraphStyles": [{"spaceBefore": 0, "spaceAfter": 0}], "textType": "point", "characterStyles": [{"fontPostScriptName": "SourceHanSerif-Heavy"}], }, } ] }, "outputs": [ { "href": "out_url", "storage": "external", "type": "vnd.adobe.photoshop", "overwrite": true } ] }
After reading through the examples it looks like the way to use the api is to:
That's according to some of the example code and documentation here.
Over the last few years the trend has been to start using the await
behavior and not proceed in the code block until thee final response is returned from the call.
Is the polling behavior part of all the api or is it possible to make a call to the API and some how tell it to not send a response until everything is complete?
var psdURL = "...";
var documentManifestURL = "https://image.adobe.io/pie/psdService/documentManifest";
var documentManifest = await client.getDocumentManifest(psdURL);
console.log(documentManifest);
// pseudo code
var psdURL = "...";
var documentManifestURL = "https://image.adobe.io/pie/psdService/documentManifest";
var results = await client.getDocumentManifest(psdURL);
var jobID = results.href;
// complicated polling code
// console.log(documentManifest);
Also, it may be that the sdk supports this now. I'm still reading through the documentation but much of the example code shows polling.
When I try to create a rendition and save it to S3 I am getting the following error:
{
code: 403,
details: [
{
name: 'https://s3.amazonaws.com/...',
reason: 'Unable to upload the outputs'
}
],
title: 'Access Is Forbidden',
type: 'AuthForbidden'
}
// GENERATE A NEW TOKEN
const authDetails: string = await this.generateIMSToken(clientIdAndApiKey, clientSecret);
let authInfo = JSON.parse(authDetails);
authToken = authInfo.access_token;
// CREATE PS API OBJECT
const client = await sdk.init(ims, clientIdAndApiKey, authToken);
// GET SIGNED URL
var signedPSDGetURL = await getSignedUrl(key, bucket);
// CREATE SIGNED URL FOR SAVING THE OUTPUT
var signedPutURL = await getSignedPutUrl(putKey, bucket);
// CREATE DOCUMENT RENDITION
var psdInputOptions = {
href: signedPSDGetURL,
storage: sdk.Storage.EXTERNAL
}
var psdOutputOptions = {
href: signedPutURL,
type: sdk.MimeType.PNG,
storage: sdk.Storage.EXTERNAL,
overwrite: true
}
const renditionResults = await client.createRendition(psdInputOptions, psdOutputOptions);
console.log(renditionResults);
The results are:
Job {
getJobStatus: [Function: bound __getJobStatus] AsyncFunction,
url: 'https://image.adobe.io/pie/psdService/status/....',
jobId: '...',
outputs: [
{
input: 'https://s3.amazonaws.com/...',
status: 'failed',
created: '...',
modified: '...',
errors: [Object]
}
],
_links: {
self: {
href: 'https://image.adobe.io/pie/psdService/status/...'
}
}
}
I don't know what else I need to do
When following the examples the following code works but just now I'm getting back this error:
PhotoshopSDKError: [PhotoshopSDK:ERROR_UNAUTHORIZED] 401 - Unauthorized ({"error_code":"401013","message":"Oauth token is not valid"})
const sdk = require('@adobe/aio-lib-photoshop-api');
const client = await sdk.init(imsOrgId, clientIdAndApiKey, authToken);
var documentManifestURL = "https://image.adobe.io/pie/psdService/documentManifest";
var documentManifest = await client.getDocumentManifest(psdURL); // error here
The error happens on the call to getDocumentManifest()
Shouldn't the error occur when calling client.init()
?
Is there a way to tell if the token expired or if the token is not valid?
How long do tokens last? The getting started page says tokens are valid for one hour in part but 60 days in another part. Maybe it's two different things. See the text in the screen shot, "...it is good for 60 days":
I am able to call client.createCutout() and get a invalid input but not an 401. The call fails but it is not a 401 error.
In the documentation there is mention of an example config.json file but I don't see it in the project. It is referenced here:
The example code references a psdService URL and that seems to be defined in the config.json.
On the following page the example code contains references to the domain "host" as shown here:
const libFiles = require('@adobe/aio-lib-files')
const sdk = require('@adobe/aio-lib-photoshop-api')
async function sdkTest() {
try {
// initialize sdk
const files = await libFiles.init();
const client = await sdk.init('<ims org id>', '<api key>', '<valid auth token>', files)
// call methods
// auto cutout...
const result = await client.createCutout('http://host/input.jpg', 'path/output.jpg')
console.log(result)
This is not helpful to use example domains because there is no way to test if that code works or not because it's not pointing to a real example.
Please use real examples so we can know that when errors occur if it is our code.
Before:
const result = await client.createCutout('http://host/input.jpg', 'path/output.jpg')
console.log(result)
After:
const result = await client.createCutout('http://www.adobe.com/test-psd.psd', 'path/output.jpg')
console.log(result)
https://github.com/adobe/aio-lib-photoshop-api?tab=readme-ov-file#usage
I am trying to use Adobe API cutout/mask. As per the document i have created a GET and PUT. According to the document i also generated the required access token. For PUT operation i am using my own Java Servlet with PUT method. When i try to run my script, adobe API GET operation is successful. My doPUT method is invoked by Adobe API. I am able to create an inputstream. However, when i save the imputstream as png file then it i s not in the proper format
It seems while trying to save inputstream i should filter some bytes. How to determine the bytes which needs to be saved for cutout or mask. There is nothing in the HEADER information which i can use Are there any bytes which i can use to validate the start and end of PNG file content. I have tried to look for "IEND" + 4 bytes. However, still it is a corrupted file
ServletInputStream fis=req.getInputStream();
byte b[]=new byte[4];
int data=fis.read(b);
boolean fosstream = true;
while(data !=-1)
{
if(fosstream)
byteArrayOutputStream.write(b);
String string = new String(b, StandardCharsets.UTF_8);
if(string.equalsIgnoreCase("IEND")) {
fosstream = false;
data=fis.read(b);
byteArrayOutputStream.write(b);
}
data=fis.read(b);
}
byte[] bytesRead = byteArrayOutputStream.toByteArray();
fos.write(bytesRead);
fos.flush();
fis.close();
There's a lot of documentation and examples on the PS API and as I've worked with it, there appears to be a client.sdk library that runs in nodejs. I don't see many examples for this anywhere but the library is very user friendly and designed in a modern way.
Suggestion is to add code examples for the sdk across the rest of the documentation and examples:
More examples here:
https://github.com/adobe/aio-lib-photoshop-api?tab=readme-ov-file#usage
Also, it should be noted I couldn't get the client sdk to work unless I generated a new token each time first before calling a client function. Although, I could have it setup wrong.
Using VSCode with the library there doesn't seem to be auto complete on the API. No type definitions (or asdocs).
If I follow the example code from here:
const client = await sdk.init(imsOrgId, clientIdAndApiKey, authToken);
client. // does not show auto complete of object members
Autocomplete to show documentation in VSCode
No autocomplete and no documentation in VSCode
Create a new node project and then follow the instructions here to import the library and then start to type the example code in vscode. You would expect to see auto complete.
https://github.com/adobe/aio-lib-photoshop-api?tab=readme-ov-file#usage
OSX
https://github.com/adobe/aio-lib-photoshop-api?tab=readme-ov-file#usage
Follow instructions here:
https://github.com/adobe/aio-lib-photoshop-api?tab=readme-ov-file#usage
is it possible to call one PSD with lots of replacement image ?
What i'm seeing is one replacement image with lots of psd
usually psd is huge and jpg for replacing is small
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.