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?

Zanna
  • 69,223
  • 56
  • 216
  • 327
user871199
  • 883
  • 1
  • 8
  • 20
  • 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: https://www.blog.pythonlibrary.org/2010/03/28/getting-photo-metadata-exif-using-python/) – 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 Answers1

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'
WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401