Download and Open Web Image In Photoshop

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: xbytor, DavideBarranca, Paul MR

AnilTejwani
Posts: 15
Joined: Wed Feb 22, 2017 5:37 pm

Download and Open Web Image In Photoshop

Postby AnilTejwani » Mon Feb 11, 2019 11:46 am

Hi,

Is it possible to download and open an web-image in photoshop?

Example if I do this *manually* it works

i. Open Photoshop,
ii. click file-> open
iii. paste the web image url ( example 'https://tejwani.com/wp-content/uploads/ ... de1-01.jpg' )
it takes a while but open the file in photoshop [it downloads in windows cache(I am on Windows) and opens it].

I am not able to script the same thing.
Example the code below

Code: Select all

var fName = 'https://tejwani.com/wp-content/uploads/2018/02/slide1-01.jpg';
var thisFile = File(fName);
app.open(thisFile);

Any ideas or work around?

Thanks in advance

User avatar
joonaspaakko
Posts: 6
Joined: Mon Apr 16, 2018 8:53 am

Re: Download and Open Web Image In Photoshop

Postby joonaspaakko » Tue Feb 26, 2019 1:11 pm

Pasting the image into Photoshop is quite different from that code example. When you're copying the image, you're not copying the image url, but the image itself. When you finally paste it into Photoshop, it simply takes what is in the clipboard and places it in the document. So it's not photoshop that downloads the image.

Edit: I realized now that you explicitly said you paste the url into PS. That's not a PS feature I'm aware of. Is this possibly something they introduced in a recent CC update?

That said, I found this on stackoverflow:

Code: Select all

app.system("curl -o ~/Desktop/test.png https://placekitten.com/200/300")

Here's some more discussion about that method/post from stackoverflow.

So you should be able to do something like this:

Code: Select all

var file = new File('~/Desktop/kitty.jpg');
app.system("curl -o "+ file.fsName +" https://placekitten.com/200/300");
app.open( file );
file.remove();

AnilTejwani
Posts: 15
Joined: Wed Feb 22, 2017 5:37 pm

Re: Download and Open Web Image In Photoshop

Postby AnilTejwani » Tue Mar 05, 2019 4:55 am

Here's some more discussion about that method/post from stackoverflow.
So you should be able to do something like this:

Code: Select all

var file = new File('~/Desktop/kitty.jpg');
app.system("curl -o "+ file.fsName +" https://placekitten.com/200/300");
app.open( file );
file.remove();
That did it. Thanks a lot for your help.


Return to “Photoshop Scripting - General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests