Applescript for serious web-application ?

Hey all,
i need a solution for a workflow which ill describe in a sec. I dont know if applescript is the right approach for solving parts of this problem, thats why i would appreciate any tips or suggestions from you guys !

Summary: cut an existing (big) image into pieces according to area-selections areas made by a web-interface

Workflow:

  • upload an image (huge) via FTP to a server
  • create selections for this image via a web-interface to cut it into pieces
  • calling an applescript from the web-interface to use an application (e.g. Photoshop, built in graphics function - any graphics application) that will cut the image into pieces by the selections made in the previous step.
  • save the parts of this image in a color-space of choice (e.g. RGB,CMYK etc)
  • create an archive of the images
  • return information about the finished process to the web-interface or via email.
  • return information about the finished process to a database

In short again:
Upload an image and use a web-interface to cut it into pieces. Then receive information about the finished process via the Interface and/or email and have the finished job written into a database.

So far i used an .acgi-script to control Photoshop with applescipt. This is - well - the single-user solution. I cant imagine Photoshop being a Server-side application → this is somehow weird, right ?
The other approach i used was via the image-function of PHP - but this is a huge timeout-problem.

So can applescipt - in combination with other techniques - be the right approach for controlling this server-side orkflow ?
Is there examples that you know where a similar apllescript-workflow is used successfully ?
Is there other techniques that would help this workflow ?

I know that a lot of questions and maybe applescript is the wrong approach - but as i was able to achieve very good results for a single-user-solution i just wonder if apllescript is able to control this workflow server-side.

thanks a lot for comments or suggestions, guys !

tdmf

I don’t have experience in this field, but I’d say you can’t use AS in a server for a serious project (though you can, there are other languages much more robust, and specifically concibed for servers, such as perl or php).
I don’t know neither PHP image-processing power, but I think you could use the set of command-line tools called “ImageMagick” (which you can invoke from PHP as well as AppleScript), which are reliable and much faster than controlling PS via apple-events, I guess. Google for it, or just wait for a serious geek opinion :smiley:

thanks a lot for your reply !

i tried the various methods for manipulating images via PHP. ImageMagik isnt a solution nor are the built in functions via the GD-Library. The problem that comes with PHP is the timeout of the script. Although you can adjust the timeout-setting to your needs, these solutions dont provide color-spaces and enough file-formats.

I found really good stuff on http://www.equilibrium.com/ in the meantime. This looks like a really professional approach to server-side image-manipulation.

I think their software will be a solution (if the price is right :wink: ) !

thanks again
tdmf

PS: But still - if there ARE good working ways with applescript - id appreciate any suggestions :wink:

You don’t say anything about how the system will be used. Finding the right solution will depend on factors like:

  • Who’s going to have access to it? (Single user/multiple users? Private intranet/public web?)

  • Does it need to process multiple jobs in parallel or can it queue them for processing one at a time? (A web frontend to a desktop app like PS would be ill-suited to the former.)

  • How does the web UI need to work? (Interactive sessions? Or just fill in a form and submit?)

  • What sort of user feedback is required, and when? (There’s significant differences between handling each job as an interactive session with browser-based feedback, and treating it as a simple ‘fire-and-forget’ process where users post the job and receive an emailed completion report at a later date.)

hi hhas,

Multiple Users muste be able to acess the frontend via the web (login). The Frontend and Usermanagement will be provided by a XAMP-Solution.

Of course the jobs would have to be queued - the images are way to large to process multiple at once.

The way the image will be cut will be defined by the user via a form. This form will then be submitted and the job will be posted to a database. A cronjob should check the database for new jobs.

The feedback via email should available when the job is finished/processed.

thanks a lot for your interest in my problem !

tdmf

Sounds like you’ve got that part pretty well figured out. Certainly, you wouldn’t want to use ACGI for anything except the most trivial web interface; it just doesn’t have the established library/framework support you’ll get with languages like PHP, Perl, Python, etc.

Well, you could process images concurrently if you wanted to (with suitable tools), but there’s probably no need to when users aren’t sticking around for the results anyway. Much simpler for yourself (and kinder to your server:) just to queue them as you say.

Since there’s no rush for results, I imagine periodically polling the DB whenever your image processing system is idle will do the job. e.g. You could use a simple daemon that repeatedly checks the DB for pending jobs and either gets the job details and executes the image processing code if one is found or sleeps for a period of time if not. (There’s an article on oreillynet.com that does something similar with iTunes.) Or you could also set up your AS script as a stay-open applet and have it poll the DB from its idle handler. If you need to use the Unix shell to communicate between the two sides, see man osascript and AppleScript’s ‘do shell script’. The only other thing to mind is that the daemon/stay-open AppleScript and GUI apps need to run under a normal user account, but I don’t think that should present a problem here.

Sounds simple enough; no shortage of web/unix stuff to take care of that. Presumably you’d hang that step off the DB too - have it keep track of progress for each job via an enumerated field containing values like “to process”, “processing”, “to notify success”, “to notify failure”, “notifying”, “finished” and “failed” that are advanced on the completion of each step.

Anyway, HTH

has

This is interesting - i always thought i couldnt access a DB like MySQL from applescript! Is there a way ?

I don’t know if there’s any scriptable apps that provide a MySQL frontend, but you can control MySQL from the unix shell, and AS allows you to execute shell scripts via its ‘do shell script’ command. Whether you’d want to run an AppleScript process for prolonged periods of time is another question - the language isn’t hugely robust and can leak memory - but it’s something to consider anyway. Yet another option may be to write all your DB-polling and PS-scripting stuff in Perl or Python instead of AS; both languages have very good third-party support for both MySQL and application scripting.

HTH