4

I have a few gigabytes of digital photos collected over the years in various directories. My current need is to look for photos in portrait mode as against landscape mode. I am trying to write a shell script with the help of the find and exif commands to see if I can get a list of images.

Portrait mode exif information shows that tag "Pixel Y Dimension" is larger than "Pixel X Dimension"

I have managed to get the right commands to get width and height of images:

exif -t 0xa002 image.jpg | grep Value | cut -d' ' -f 4 #Width
exif -t 0xa003 image.jpg | grep Value | cut -d' ' -f 4 #Height

How could I combine this with the find command so that I can find images where height is larger than width?

And, is there any way I can make it more generic - like find photos with certain date (in the exif data) or exif values?

  • It seems that it's much easier to write a simple python script than try to fit this task in bash (this article can help: blog.pythonlibrary.org/2010/03/28/…) – user502144 Aug 11 '17 at 21:43
  • @user502144 if you can write a python script to do this and post it as an answer, that would be awesome! – Zanna Aug 19 '17 at 21:48
1

We can use a modified version of this answer: How to find all images with a certain pixel size using commandline?

find . -iname "*.jpg" -type f -exec identify -format '%w %h %i' '{}' \; | awk '$1<$2'

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.