Question

I want to interact with a Photoshop file and create images using its actions and smart objects.

Is there any php or C# API to can do it?

Was it helpful?

Solution 3

This sound like hard but some companies seems to make it work. Xee can read PSD too (and has an epic comment about this format in the source code).

But to quote someone over at HN:

PSD was never intended to be a data interchange format: it is the serialization format of a single program that has more individual unrelated features that actual people rely on than almost any other piece of software and has maintained striking amounts of backwards compatibility and almost unbroken forwards compatibility during its over two decades of existence. This product's "file format" needs to be critiqued in this context, along with similar mega-programs like Office. I am thereby having a difficult time fathoming why anyone would think that a PSD file is thereby going to be some well-organized file format that they should easily be able to parse from their own application is just naively wishful thinking: even other products from Adobe have limitations while opening these files; to truly manipulate these files you really need to be highly-compatible with Photoshop's particular editing model (hence the conceptual difference between these two classes of file format).

I would recommand to look at Xee for a server side utility.

Good luck.

OTHER TIPS

First of all, I would like you to reflect on the legality of such a thing. Would Adobe let you practically just proxy their application to the web? I see they have a lot of licenses so maybe one of them actually grants you permission to do this (however, there could still be caveats so I suggest you read up on that). As that's not the question, I won't talk about this anymore, I just wanted to to mention it as it should be relevant.

Now, for the actual question - if you look at Microsoft Office Interop, Microsoft states that it is unsupported in a server-side environment. Go to this Microsoft page and read Problems using server-side Automation of Office in the More information section.

There are several issues if you decide to run a regular client application server-side, as stated on the mentioned page, but one of the most significant issues is the following:

Interactivity with the desktop: Office applications assume that they are being run under an interactive desktop. In some circumstances, applications may need to be made visible for certain Automation functions to work correctly. If an unexpected error occurs, or if an unspecified parameter is needed to complete a function, Office is designed to prompt the user with a modal dialog box that asks the user what the user wants to do. A modal dialog box on a non-interactive desktop cannot be dismissed. Therefore, that thread stops responding (hangs) indefinitely. Although certain coding practices can help reduce the likelihood of this issue, these practices cannot prevent the issue entirely. This fact alone makes running Office Applications from a server-side environment risky and unsupported.

While this is written by Microsoft for their product, these are more or less applicable to any regular client application. And even if you still decided to go with this approach, as Neville K already suggested, it would be a very resource-hungry task.

Considering the above, I would maybe ask a different question, along the lines of "What library or server-side app to use for doing whatever you need to do with images".

Based on this link, you can do this things with Photoshop SDK: "With the Photoshop SDK, you can enable your apps to drive and/or communicate with Photoshop CS6 (version 13.0.0 or later) via a TCP connection. It’s now possible to create an eBook of Photoshop tutorials that allows users to drive actions in Photoshop CS6 from within the eBook"

You can use the scripting interface to kick off "Shell" tasks from any web language if you really want to.

However, I'd seriously worry about this approach - the memory requirements for Photoshop are such that you could only support a couple of users, and you'd need a fairly complex polling mechanism to check for the results of the "shell" task. Photoshop was simply not designed to power web sites in this way.

Consider using graphics libraries instead - I've used ImageMagick with great effect in the past.

Heed the warnings that you really can't process more than 1 or 2 images at a time with photoshop without crashing your server, so just putting it on your webserver is a non-starter. A lighter weight image library is much better for most tasks.

But you could queue up jobs from your web application and then process them on another computer, or limit it to just one at a time.

Adobe has macros and a full action/javascript based scripting environment that you could kick off from commandline or com.

Adobe Scripting Guide

http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop_cs5_scripting_guide.pdf

For older versions of photoshop you can use the macro functionality to Record an action. Then, create a droplet from the action. Call the droplet from the command line with an image file as the sole parameter. The path to the image file probably needs to be an absolute one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top