ExifTool Forum

ExifTool => Newbies => Topic started by: kkaiser on April 06, 2020, 12:11:18 PM

Title: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 12:11:18 PM
I have a large Apple OS X photoslibrary that has possibly thousands of small photos 240x180 and smaller. How can I scan for these and move them all to an album in the same photoslibrary?
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: StarGeek on April 06, 2020, 12:15:41 PM
I wouldn't know how to move them to a different album, but to scan for images 240x180 and smaller and move them you would use a command like this

exiftool -if '$ImageWidth<=240 and $ImageHeight<=180' '-directory=/path/to/new/directory' /path/to/source/images/
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 12:31:57 PM
I tried this entry;

exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory='/Volumes/Photos\ by\ Year/photos-by-year/2019-Small' /Volumes/Photos\ by\ Year/photos-by-year/2019-D/

But the system immediately responded with:
quote>

Thats all it said, so I tried putting single quotes around the source file as well but I got the same response.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: StarGeek on April 06, 2020, 12:35:28 PM
Quote from: kkaiser on April 06, 2020, 12:31:57 PM
I tried this entry;

exiftool -if '$ImageWidth<=240 and $ImageHeight<=180' '-directory='/Volumes/Photos\ by\ Year/photos-by-year/2019-Small' /Volumes/Photos\ by\ Year/photos-by-year/2019-D/

I think your quotes are off. You seem to have an extra quote in the directory part.

Maybe this?
exiftool -if '$ImageWidth<=240 and $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/2019-Small' '/Volumes/Photos by Year/photos-by-year/2019-D/'
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 12:43:02 PM
Looks like it must have been the '\' in the directory name. Thank you, this is now working.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: StarGeek on April 06, 2020, 01:26:43 PM
The backslashes are fine if they're not enclosed in quotes (not sure if they work if there are quotes around them).  But notice that you have three quotes in this section
'-directory='/Volumes/Photos\ by\ Year/photos-by-year/2019-Small'
That's what messed it up.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 02:20:55 PM
I see that now. Thanks for the help.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 03:29:10 PM
@StarGeek Going back to my original note I was hoping to run my script against the entire photoslibrary like this;

exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' '/Volumes/Photos\ by\ Year/photos-by-year/PastYears.photoslibrary'

It responds almost instantly with;

1 directories scanned
    0 image files read

I know this is wrong because I can see hundreds of photos that are that size or less. I also tried with /originals on the end of the string but I got exactly the same response. Thoughts?
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 06, 2020, 03:38:23 PM
Do you see the jpg files with this command?:

ls '/Volumes/Photos\ by\ Year/photos-by-year/PastYears.photoslibrary'

If not, what is the directory that actually contains the image.  If they are inside a bunch of subdirectories in photoslibrary, then just add -r to the command to recurse into subdirectories.

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 06, 2020, 03:47:51 PM
No this is what I get:

KKAISER@KeithsMacMini-2 ~ % ls '/Volumes/Photos\ by\ Year/photos-by-year/PastYears.photoslibrary'
ls: /Volumes/Photos\ by\ Year/photos-by-year/PastYears.photoslibrary: No such file or directory

Even if I add the /originals I get the same.

I think the issue is ExifTool doesn't work with the Apple photoslibrary which is some kind of construct.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 06, 2020, 08:33:34 PM
I don't see how you come to that conclusion.  The ls command can't find the file you specify.  This has nothing to do with ExifTool.  "ls" is a system utility.

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 07, 2020, 12:11:20 AM
@PHil_Harvey No,no, I'm sorry I misstated the issue. I thought maybe the issue was ExifTool not working with photoslibrary but it actually works fine. I wasn't talking about ls which I'm very familiar with. So sorry for my booboo.

My code looks like below with the results below that. But there are over 10,000 photos in this library that should be found and its not finding any. Any thoughts on that?

exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/' -r

   17 directories scanned
110602 files failed condition
    0 image files read
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 07, 2020, 07:10:50 AM
Your condition works fine for me on MacOS.  I would say that there are no files in that directory which are this small.

You can try the command on a single known image to verify that it works.  For example:

% exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' -imagesize t/images/Writer.jpg
Image Size                      : 8x8


BTW, what ExifTool version are you using?  The current version is 11.83.

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 07, 2020, 10:22:44 AM
Using version 11.93, I did your test and got:

% exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' -imagesize /Volumes/Photos\ by\ Year/photos-by-year/Small/24669387771.jpg 
Image Size                      : 64x96

Which is great, but the same image in the phototslibrary doesn't get moved. Hmmmmm!
I'm going to adjust the script a little and try it again.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 07, 2020, 07:07:47 PM
I ran the following script and again had no files moved, yet over 10,000 are in the 110,602.

% exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' -r '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/'
   17 directories scanned
110602 files failed condition
    0 image files read
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: StarGeek on April 07, 2020, 08:03:28 PM
I'm not sure what to suggest.  That command works properly.  If it isn't finding anything, then there probably isn't any files of that size.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 07, 2020, 09:07:41 PM
The small jpg you tested was in the directory

/Volumes/Photos by Year/photos-by-year/Small/

yet you are running the command on this directory

/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/

are you sure there are small images in the "originals" directory?  ExifTool is saying that there aren't.

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 07, 2020, 10:04:38 PM
This is the second image in the /originals/0 file, its only 75x75, or am I reading it wrong?

% exiftool /Volumes/Photos\ by\ Year/photos-by-year/PastYears.photoslibrary/originals/0/023820A9-7D52-4D40-AB0F-322BFBFE6205.jpeg
ExifTool Version Number         : 11.93
File Name                       : 023820A9-7D52-4D40-AB0F-322BFBFE6205.jpeg
Directory                       : /Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/0
File Size                       : 2.7 kB
File Modification Date/Time     : 2020:01:22 17:51:52-06:00
File Access Date/Time           : 2020:04:07 21:03:00-05:00
File Inode Change Date/Time     : 2020:04:07 14:01:00-05:00
File Permissions                : rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Exif Byte Order                 : Little-endian (Intel, II)
Modify Date                     : 2012:02:28 12:19:17
Artist                          : We Are The Rhoads 1
Copyright                       : We Are The Rhoads
Image Width                     : 75
Image Height                    : 75
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 75x75
Megapixels                      : 0.006
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 08, 2020, 07:17:33 AM
So what happens when you run this command?:

exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' -r '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/0/023820A9-7D52-4D40-AB0F-322BFBFE6205.jpeg'

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 08, 2020, 09:42:17 AM
% exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' -r '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals/0/023820A9-7D52-4D40-AB0F-322BFBFE6205.jpeg'

    1 image files updated

Now I'm even more confused.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 08, 2020, 10:26:25 AM
I'm running (yes running):

exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' -r '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals'

And its working. In just a few minutes it has identified and moved 1140 small photos to the Small2 file.

It looks like the only difference is the / at the end of originals. Is that true?

Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 08, 2020, 01:53:23 PM
It finished;

% exiftool -if '$ImageWidth<=240 and  $ImageHeight<=180' '-directory=/Volumes/Photos by Year/photos-by-year/Small2' -r '/Volumes/Photos by Year/photos-by-year/PastYears.photoslibrary/originals'                                           

   17 directories scanned
101251 files failed condition
9350 image files updated

Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: Phil Harvey on April 08, 2020, 03:42:18 PM
The slash at the end won't matter.

Ah... The problem was that you had a funny Unicode non-breaking space in your -if condition:

'$ImageWidth<=240 and  $ImageHeight<=180'

Immediately after the "and" is the funny character.  You can get this by copying and pasting from your web browser.

If I copy and paste your bad command and add the -v option, I see this warning:

Condition: Unrecognized character \xC2; marked by <-- HERE after }<=240 and<-- HERE near column 29

- Phil
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: StarGeek on April 08, 2020, 06:38:50 PM
That was probably my fault.  I usually make sure I don't have double spaces when I list a command here because the forum does that.  I didn't do that in the example I gave.  Fixed.
Title: Re: Create an album of thumbnail size photos from Apple Photoslibrary
Post by: kkaiser on April 08, 2020, 08:23:38 PM
Poop happens! All is well.