Copy link to clipboard
Copied
Hi people,
I'm new to Photoshop scripting and i'm trying to create a script that creates a new layer and imports an online image based on selection made by user (to import placeholder using placehold.it)
var document = app.activeDocument;
var width = document.selection.bounds[2].replace(' px','');
var height = document.selection.bounds[3].replace(' px','');
app.open(new File("http://placehold.it/"+width + "x" + height)); // Here is my problem I can't import an image like that ![]()
app.activeDocument.activeLayer.copy();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
document.paste();
So is there a way to open a distant image from jsx ?
Copy link to clipboard
Copied
Here is a link to a script by Jeff Tranberry that will let you open a file from a web URL http://www.mouseprints.net/old/dpr/OpenImageFromWeb.jsx
I couldn't find a link to the original script but that version works with the URL used. A problem I have run into with both this version and the original version is that it doesn't work will every URL. I think it has something to do with the web server. For example I can not get it to download any images from the several sites I have using the same hosting service.
Copy link to clipboard
Copied
Been some time I do recall having some problems web servers url and html. I also player with getting all images on a web page into a stack. The script did bot always work. There is no standard web site design, writing a script to handle all web design is beyond my abilities. You may also want to look at http://www.mouseprints.net/old/dpr/StackWebPageImages.jsx on my web site as well as Adobe Javascript sample socket script I started with. Its one of the scripts included in the optional Photoshop scripting downloads from Adobe's web site.
Copy link to clipboard
Copied
I don't think is has any thing to do with the web site design. I think there is something about some servers that causes this script to fail. For example here is a vaild URL that the script will not download. http://www.ps-scripts.com/images/logo1.gif
Instead of getting the image it gets a '404 Not Found' message. But that same URL in a browser shows the image.
Copy link to clipboard
Copied
I added
socket.write("GET " + sImg +" HTTP/1.1\nHost: " + domain + "\nAccept-Encoding: gzip, deflate\nConnection: keep-alive\n\n");
to be able to read some file that was on other website (mod deflate could cause some trouble)
I made this script work for any kind of images but the time is much too long, (3/4 seconds to successfully import an image on the canvas)
Copy link to clipboard
Copied
Thanks for that. It does let me download and open the logo1.gif. But it hangs the ExtendScript Toolkit editor/debugger.
Changing that line to
socket.write("GET " + sImg +" HTTP/1.0\nHost: " + domain + "\nAccept: image/gif, image/x-xbitmap, image/png, image/jpeg, */*\n\n");
is a lot faster, but still hangs ESTK.
Copy link to clipboard
Copied
Thank you two helped a lot...
Copy link to clipboard
Copied
Finally I created a panel using Adobe Configurator 4 and added a new HTML Widget with the script
_Adobe.download('url of the file' ...)
There is an example given by Adobe when you start Adobe Configurator 4.
and then I invoke the jsx that use the file and remove it at the end.
This solution is rly fast, the file is downloaded instantly ![]()
Copy link to clipboard
Copied
I do not like the way you need to configure panels for each version of Photoshop using the latest version of the configurator. Why do you need a different install for each version of Photoshop. I rather just install a Photoshop scripts that work with all versions of Photoshop. Panels just take up additional space as it is Photoshop has too many pallets and panels. I see little difference in having an addition GUI panel or Having an additional Script dialog, If you need fast access to your script you can always create an action with an assigned F key that uses the script you want quick access to. Faster then maintaining Panels installation for each Photoshop version installing then and using them. I do realize this is my opinion your may differ.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now