Image statistics on thousands URLs

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
BenCherre
Posts: 1
Joined: 2016-09-16T07:26:57-07:00
Authentication code: 1151

Image statistics on thousands URLs

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image statistics on thousands URLs

Post 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
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Image statistics on thousands URLs

Post 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...

Code: Select all

3400x1600
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image statistics on thousands URLs

Post by fmw42 »

Good point Geemack.

But my understanding is the -ping must come before the input to avoid reading the image.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Image statistics on thousands URLs

Post 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.
Post Reply