Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
lwx228
Level VII

How do I download images in bulk with JSL and save them with the name of the specified column?

For example, download the attached links and save these pictures to the C: directory.

 

2020-02-24_22-23.png

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

Here is a very simple script that I believe will do what you want

Names Default To Here( 1 );

// Create a list of all of the images
imgList = {"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/859de8ee2b9187a0e73d764fd53466e4.jpg",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/.........",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/........."};

// Read in and write each of the images
For( i = 1, i <= N Items( imgList ), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);

 The Open() and Save Image() functions are Documented with examples in the Scripting Index.  

Jim

View solution in original post

3 REPLIES 3
Highlighted
txnelson
Super User

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

Here is a very simple script that I believe will do what you want

Names Default To Here( 1 );

// Create a list of all of the images
imgList = {"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/859de8ee2b9187a0e73d764fd53466e4.jpg",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/.........",
"http://data2.readoor.cn/files/3211195850f6ae/pdf/9213745e4f7c7b/3/........."};

// Read in and write each of the images
For( i = 1, i <= N Items( imgList ), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);

 The Open() and Save Image() functions are Documented with examples in the Scripting Index.  

Jim

View solution in original post

Highlighted
lwx228
Level VII

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

  • Thank Jim!
  • I used to write it this way, but it didn't work.

request = New HTTP Request(	Url("http://data2.readoor.cn/files/3211195850f6ae/pdf/2977675e4e6cb5/3/f0df50279eeaa6465bfaf4e93525e81a.jpg",jpg),
	Method( "GET" ),
);
img  = request << Send;
img << SaveImage( "C:/1.jpg", jpg ); 
Highlighted
lwx228
Level VII

Re: How do I download images in bulk with JSL and save them with the name of the specified column?

dt=Current Data Table();
imgList = Column( "url" ) << get values;
For( i = 1, i <= N Row(dt), i++,
	img = Open( imgList[i], jpg );
	img << Save Image( "C:\image" || Char( i ) || ".jpg", jpg );
);
Article Labels

    There are no labels assigned to this post.