It is very easy to check image dimensions using the command line. Install the exiv2 package and this allows easy retrieval of image information.
Just like this.
┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Pictures/phone5] └─$ exiv2 ui_icon_equipment.png File name : ui_icon_equipment.png File size : 8626195 Bytes MIME type : image/png Image size : 4096 x 4096 ui_icon_equipment.png: No Exif data found in the file |
This gives us a lot of information about the file. The dimensions are what we are after.
The example below tests to see if an image is over 1000 pixels wide.
┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Pictures/phone5] └─$ exiv2 ui_icon_equipment.png 2>/dev/null | awk ' NR==4 { if($4 > 1000) print $4 " x " $6 " Pixels"; else print "No adequately sized image found." }' 4096 x 4096 Pixels |
This is easily done using the awk if statements.
if($4 > 1000) print $4 " x " $6 " Pixels"; else print "No adequately sized image found." |
The awk utility is so versatile and makes this type of task very simple.
┌──(john㉿DESKTOP-PF01IEE)-[/mnt/c/Users/Intel i5/Pictures/phone5] └─$ exiv2 ui_icon_equipment.png 2>/dev/null | awk ' NR==2 { print $4 " Bytes"; print sum ($4 / 1024 / 1024) " Megabytes" }' 8626195 Bytes 8.22658 Megabytes |
The above example will print the file size of an image in bytes and then megabytes. This is also very useful.