How do I find the image with the greatest width in a group of images?

Let's say there are 50 images, and I want to know which one has the biggest width. Which commands should I use?

1

2 Answers

This command (identify from ImageMagick) output the image with the biggest width :

identify -format "%w %h %f\n" *.png | sort -n -r -k 1 | head -n 1

-format "%w %h %f = width, height, filename

Result : w h image.png

Source : Find Largest Image Dimensions in Folder :

If your images aren’t in the same folder, open a terminal and run this script from a folder contening subdirectories.

find . -iname "*.png" -type f -exec identify -format "%w %h %f\n" '{}' \; | sort -n -r -k 1 | head -n 1

Note : If you have more than one image with the same width it will only show one result. To have a list of all images sort by width remove head -n 1 from the precedent command.

4

This command will search for image widths in the current directory.

Before you have to install imageinfo with:

sudo apt install imageinfo

Then type this command

find . -maxdepth 1 -type f -iregex ".*/.*\.\(jpg\|jpeg\|png\|tiff\|bmp\svg\)" \ -exec bash -c "echo -ne {}' '; imageinfo --width {}; echo " \;\ | sort -k2 -n

If you only want the largest one add a pipe to the command above

... | tail -n 1
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like