Download and Open Web Image In Photoshop

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

Moderators: Tom, Kukurykus

AnilTejwani
Posts: 20
Joined: Wed Feb 22, 2017 5:37 pm
Location: Paraguay

Download and Open Web Image In Photoshop

Post by AnilTejwani »

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
Location: Finland

Re: Download and Open Web Image In Photoshop

Post by joonaspaakko »

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: 20
Joined: Wed Feb 22, 2017 5:37 pm
Location: Paraguay

Re: Download and Open Web Image In Photoshop

Post by AnilTejwani »

joonaspaakko wrote: Tue Feb 26, 2019 1:11 pm 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.
z3597666
Posts: 4
Joined: Thu Dec 23, 2021 3:14 am

Re: Download and Open Web Image In Photoshop

Post by z3597666 »

Is there any way not jump out of the CMD