cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lwx228
Level VIII

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
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
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
lwx228
Level VIII

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 ); 
lwx228
Level VIII

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 );
);

Recommended Articles