Download image from URL

New Here ,
Nov 08, 2016 Nov 08, 2016

Copy link to clipboard

Copied

Hi,

I need to download images from a webserver and have to display them on a catalog. This catalog should become a product catalog.

More info: The idea is that retailers can upload their product images on a webserver. An Indesign script should dynamically download these images and create a product catalog out of them. I'm currently stuck with coding the image download process. Is it possible in extendscript to download files given a URL?

Help is very appreciated.

TOPICS
Scripting

Views

5.4K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Nov 08, 2016 Nov 08, 2016

Copy link to clipboard

Copied

@Hi,

Take a look here:

Re: HTTP Upload file with Socket

I mean post with link to getURL.jsx

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 09, 2016 Nov 09, 2016

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 09, 2016 Nov 09, 2016

Copy link to clipboard

Copied

Aren't there any easier solutions?

For example, I've found this solution: javascript - How to download an image from url to use in Photoshop scripting (ExtendScript Toolkit) ...

However, it doesn't work for me since app.system() seems not to be valid. Why?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 09, 2016 Nov 09, 2016

Copy link to clipboard

Copied

However, it doesn't work for me since app.system() seems not to be valid. Why?

What is your version of PhotoShop?

app.system() is working with e.g. PhotoShop CC 2017.

Just tested Fabian's line of code from Stack Overflow with PhotoShop CC 2017.

It's working. The png landed on my desktop.
Mac OSX 10.10.5.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

Would the be a way to download the image into memory from the URL and place it into an active document rather than save it to desktop? I have thousands of products that need to have dimensions added to. I read the dimensions from a CSV file using a script. I currently have to scrape the images using an excel macro but want to see if I can scrape the image using Photoshop Javascript. I'm using OS X.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

PS-Guru  wrote

Would the be a way to download the image into memory from the URL and place it into an active document rather than save it to desktop? …

Don't think so. Placing something has to be done with a file.

And it would be done best to a linked file.

Why would you like to bring in the images without linking them? It would only bloat the file size of the InDesign document. Perhaps up to a point wher you will not be able to open the document again when file size is a couple of gigabytes.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

Hi,

Download the image to a file, place the file, embed the file, remove file from disk.

P.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 10, 2016 Nov 10, 2016

Copy link to clipboard

Copied

Thank you very much for your provided link!

In the meanwhile I tested Fabian's PhotoShop script snippet with several versions of PhotoShop.
As I can see app.system() is working with all my installed PhotoShop versions from CS4 to CC 2017 on OSX.

With PhotoShop CS3 app.system() seems to be not available.

Don't know how this will work on a Windows machine.
The command curl used by Fabian ( cURL, Client for URLs or Curl URL Request Library) should be also available on Windows.

See: https://curl.haxx.se

So downloading images from the web using ExtendScript with InDesign to the local file system should be doable by using BridgeTalk to access PhotoShop from InDesign.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

I'm using InDesign and not Photoshop. I think this is the reason why app.system() is not available.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 14, 2016 Nov 14, 2016

Copy link to clipboard

Copied

Yes. That's the reason. Are you on Windows or Mac OSX?

When on Mac OSX curl is built in and can be used with the terminal.
The terminal CLI can be reached by AppleScript. And the AppleScript can be executed by ExtendScript using method doScript() from InDesign.

Regards,
Uwe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 30, 2019 Jul 30, 2019

Copy link to clipboard

Copied

See Re: Include remote .js-file in script-file (and use it's variables)

In particular post #21 and the gist files there.

Now one can also use curl on Windows 10 not just Mac.

One can curl to the temp folder, link to indesign, embed images and then delete from temp folder.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 30, 2019 Jul 30, 2019

Copy link to clipboard

Copied

The best way of dealing with it would be using an extension that can download load the files asynchronously and when they are all downloaded the can be embed in the document. One could handle multiple documents and carry on working in indesign like that except for the interruptions for the linking and embedding.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 31, 2019 Jul 31, 2019

Copy link to clipboard

Copied

cURL worked great for me on OS X. The only issue is that until I added the delay, the script would crash because there was no file to place in the document. Now what happens on rare occasion is that a partial file get's placed and displays corrupted. This is because it had not finished downloading when it was imported.

I am going to work on writing a script that will check the file size twice and if different, wait 500ms and try again against the latest size. When the file sizes are the same, the file will be fully downloaded and ready to place in the document.

I apologize to all you InDesign folks that commented but embarrassingly I must confess, I appear to have dropped into the wrong thread. I am working in Photoshop. However, that being said, you guys knocked it out of the park and I resolved my issue! No, it's not loaded into "Memory" for placing but actually, it's not a problem. I have the files to replace the corrupted partial imports if needed.

For me, the question is Answered!

Here is what i am using at this time.

app.system("curl -o ~/Desktop/jpegs/Download_for_Dimensions/" + skuNumber + ".jpeg http://s7d6.scene7.com/is/image/domainName/" + skuNumber + "?qlt=100&printres=300&fmt=JPEG")  

    var filePath = new File(searchFolder + "/" + skuNumber + ".jpeg");  //Sets the path to the file to be placed in the current document.

$.sleep( 2000 ); /*Milliseconds*/

var checkFile = new File(filePath);

if (checkFile.exists) {

    alert(checkFile.size);

        placeEmbeded(filePath);

}

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 31, 2019 Jul 31, 2019

Copy link to clipboard

Copied

LATEST

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines