Page 1 of 1
Image statistics on thousands URLs
Posted: 2016-09-16T09:09:34-07:00
by BenCherre
Hi,
I have tens of thousands of image URLs. I would like to obtain rough statistics about their width and height.
I don't need the actual images.
I can code in several languages.
I would appreciate any tips.
Ben
Re: Image statistics on thousands URLs
Posted: 2016-09-16T09:52:06-07:00
by fmw42
Code: Select all
convert -ping URLtoImage -format "%wx%h" info:
You will have to loop over all the URLs. Are they all in one given directory?
URLs of the form http://..../someimagename.suffix
Re: Image statistics on thousands URLs
Posted: 2016-09-16T10:21:26-07:00
by GeeMack
fmw42 wrote:Code: Select all
convert -ping URLtoImage -format "%wx%h" info:
If any of the images are multi-layer GIFs, the info format might be a little more helpful by adding the filename and the position of the image in the stack to the output. This command...
Code: Select all
magick http://radar.weather.gov/Conus/Loop/NatLoop.gif -ping -format "%[w]x%[h]" info:
... will output this information...
Code: Select all
3400x16003350x15353351x15333345x15253354x15173355x15183356x15123356x1518
Adding a couple more formatting escapes and some line feeds like this...
Code: Select all
magick http://radar.weather.gov/Conus/Loop/NatLoop.gif -ping -format "%[f][%[p]] %[w]x%[h]\n" info:
... will show those dimensions more clearly for each layer of the image, like this...
Code: Select all
NatLoop.gif[0] 3400x1600
NatLoop.gif[1] 3350x1535
NatLoop.gif[2] 3351x1533
NatLoop.gif[3] 3345x1525
NatLoop.gif[4] 3354x1517
NatLoop.gif[5] 3355x1518
NatLoop.gif[6] 3356x1512
NatLoop.gif[7] 3356x1518
If only the dimensions of the first layer of the image are important, the "[0]" can be attached to the filename in the image URL, like this...
Code: Select all
magick http://radar.weather.gov/Conus/Loop/NatLoop.gif[0] -ping -format "%[w]x%[h]" info:
... which will give just the first set of dimensions...
Re: Image statistics on thousands URLs
Posted: 2016-09-16T11:00:16-07:00
by fmw42
Good point Geemack.
But my understanding is the -ping must come before the input to avoid reading the image.
Re: Image statistics on thousands URLs
Posted: 2016-09-16T13:34:44-07:00
by GeeMack
fmw42 wrote:But my understanding is the -ping must come before the input to avoid reading the image.
Thanks. I ran a couple tests with URLs pointing to some large JP2 files from NASA and a multi-layer GIF from NOAA, and it looks like you're correct. In every case it was notably faster when putting the "-ping" ahead of the URL.