Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hopefully this separate post is warranted as I was concerned that this answer would be lost as simply a comment on my previous post. And why do think this deserving of a separate post, you ask? Well, I think I have found an answer.</p> <p>Granted I am using the CLI version rather than libcurl (in your language of choice) but I futzed around enough until I got a working answer. It is as follows:</p> <pre><code>curl -r 0-25 --silent http://www.google.com/logos/giroux1.jpg | identify -format "%wx%h" - </code></pre> <p>What is happening here in the above example is CURL is using the -r flag to request only the first 25 bytes of the file and piping that to the imagemagick command called IDENTIFY where it extracts the dimensions and prints them out in the specified format.</p> <p>For more about the info that you can extract with IDENTIFY visit <a href="http://www.imagemagick.org/script/identify.php" rel="nofollow noreferrer">http://www.imagemagick.org/script/identify.php</a></p> <p>To make the command a bit more script friendly I would add "2> /dev/null" to the end to suppress error messages (stderr):</p> <pre><code>curl -r 0-25 --silent http://www.google.com/logos/giroux1.jpg | identify -quiet -format "%wx%h" - 2&gt; /dev/null </code></pre> <p>Unlike GIF images where the dimensions appear to be tightly tied to the first 10-20 bytes, there does not appear to be a fixed quantity of bytes required to get to the dimensions data from a JPEG. Some more testing has revealed that for large images you might need to request up to the first ~10k to get to the dimensions data. A good example is the following 4MB image from NASA: <a href="http://veimages.gsfc.nasa.gov/17921/southern_africa_25jul02_lrg.jpg" rel="nofollow noreferrer">http://veimages.gsfc.nasa.gov/17921/southern_africa_25jul02_lrg.jpg</a> I found that no less than 5971 bytes will render the dimensions (10836 x 9324) but I guess that is better than having to download the whole thing.</p> <p>Point being...your mileage may vary, so try it out yourself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload