Fast way to get image dimensions (not filesize)

前端 未结 8 1827
独厮守ぢ
独厮守ぢ 2021-01-29 23:03

I\'m looking for a fast way to get the height and width of an image in pixels. It should handle at least JPG, PNG and TIFF, but the more the better. I emphasize

8条回答
  •  情深已故
    2021-01-29 23:11

    tldr: file "imagename" will do

    works with webp, all jpg formats (jpeg,jpg200,..),

    Sample output looks like

    JPEG image data, JFIF standard 1.02, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 650x400, frames 3

    load the output of file to a python list & use the 4'th field in the list.

    FYI, did optimize around 18000+ images to cut down network traffic.

提交回复
热议问题