Making HTTP calls & interacting with Disk from within Photoshop

This blog post has sat in Draft for far too long. I have no intention of writing a full article so let’s let the code live on.

Using the Adobe Photoshop CS ExtendScript Toolkit (which is included by default in the PS scripting environment), we can make HTTP calls, write to disk, and have some fun. Imagine exposing a REST API of batch jobs to execute and having Photoshop pull them down and execute them in near real-time. I did this and it works.

Here is a simple gist of opening a connection and writing the response to a file.

function execute_modifications() {
	var doc = activeDocument;
	var reply = "";
	var conn = new Socket;
	// access some URL
	if ( ("")) {
		// issue http command
		conn.write ("GET /index.html HTTP/1.0\n\n");
		// read connection response (and a lot of it)
		reply =;
		var file;
		try {
			file = new File('~/.ps_actions.cnf');
			if (!'e')) {
				alert('failed to open file: ' + file.error);
			if (!file.write(reply)) {
				alert("Failed to write to file: " + file.error);
		} catch(e) {
			alert('Failed to write to file: ' + e + ":" + e.line);
		} finally {

More documentation at:
Javascript Tools Guide (Page 17 is where it gets interesting)
Photoshop Scripting

Leave a Reply

Your email address will not be published. Required fields are marked *