Hello.
Existing exiftool code to only output if;
is regular file
is non zero size
is mime type starting with: image/
is not file extension: NEF, RAF, ARW, CR2
is file extension: JPEG, TIFF, PNG, WEBP ,PSD ,GIF
Problem: For some odd reason Adobe Photoshop Images (PSD) are;
Not MIME Type: "image/"
They are: MIME Type: application/vnd.adobe.photoshop
exiftool -t -q -q -m -p '$filename; $filetype; $mimetype; $imagewidth; $imageheight' \
-if '-e $filepath && -f $filepath && -s $filepath
&& $mimetype =~ m"^image/[^x]"
&& $filetypeextension !~ m"\.(?:NEF|RAF|ARW|CR2)$"i
&& $filetype =~ m"(JPEG|TIFF|PNG|WEBP|PSD|GIF)"i'
Questions;
a) Is -filetype a better choice to identify images from non images (instead of -mimetype) ?
A negative I foresee is different spelling of filetypes e.g. jpeg/jpg/JPG/JPEG , or TIFF/tiff/tif/tiff
Or...
b) Should I add another -mimetype for the Adobe .psd ?
$mimetype =~ m"^image/[^x]" or $mimetype =~ m"^application/vnd.adobe.photoshop"
Thank you.
System;
-Linux Mint 18.4 64bit Cinnamon.
-exiftool 11.10
-bash 4.3.48
Quote from: captured on October 29, 2018, 08:12:45 PM
a) Is -filetype a better choice to identify images from non images (instead of -mimetype) ?
A negative I foresee is different spelling of filetypes e.g. jpeg/jpg/JPG/JPEG , or TIFF/tiff/tif/tiff
Or...
I would have thought that MimeType would be good, but you would need to special case PSD/PSB files. The FileType is always the same case.
Quoteb) Should I add another -mimetype for the Adobe .psd ?
$mimetype =~ m"^image/[^x]" or $mimetype =~ m"^application/vnd.adobe.photoshop"
Or you could add
or $filetype =~ /^(PSD|PSB)$/.
- Phil
Thanks Phil.
I tried copy and pasting your suggesstion but it did not produce.
exiftool -t -q -q -m -p '$filename; $filetype; $mimetype; $imagewidth; $imageheight' \
-if '-e $filepath && -f $filepath && -s $filepath
&& $mimetype =~ m"^image/[^x]"
or $filetype =~ /^(PSD|PSB)$/.
&& $filetypeextension !~ m"\.(?:NEF|RAF|ARW|CR2)$"i
&& $filetype =~ m"(JPEG|TIFF|PNG|WEBP|PSD|GIF)"i'
Regards.
I think you need some brackets in there to force the correct order of evaluation (the "or" operator is super-low precedence).
- Phil
Is this OK ?
exiftool -t -q -q -m -p '$filename; $filetype; $mimetype; $imagewidth; $imageheight' \
-if '-e $filepath && -f $filepath && -s $filepath
&& $mimetype =~ m"^image/[^x]" or $filetype =~ m"^(PSD|PSB)"
&& $filetypeextension !~ m"\.(?:NEF|RAF|ARW|CR2)$"i
&& $filetype =~ m"^(JPEG|TIFF|PNG|WEBP|PSD|GIF)"i'
It worked.
Regards.
I was thinking more along these lines:
exiftool -t -q -q -m -p '$filename; $filetype; $mimetype; $imagewidth; $imageheight' \
-if '-e $filepath && -f $filepath && -s $filepath
&& ($mimetype =~ m"^image/[^x]"
or $filetype =~ /^(PSD|PSB)$/)
&& $filetypeextension !~ m"\.(?:NEF|RAF|ARW|CR2)$"i
&& $filetype =~ m"(JPEG|TIFF|PNG|WEBP|PSD|GIF)"i'
I also removed a "." after one of the regular expressions in your first post, but I see you fixed that too.
- Phil
Thank you very much Phil.
Will change.
Oops, spoke too soon.
I copied and pasted your most recent and it stopped after 7 seconds.
Stumped, I am.
Phil.
Thank you for your help.
I couldn't figure out why my system doesn't like;
or $filetype =~ /^(PSD|PSB)$/
This is working, so I'm back to work.
or $filetype =~ m"^(PSD|PSB)"
Best to you.
[Solved]
Ah, right. My mistake. The "$/" is interpreted as a newline by ExifTool. You would need to change this to "$$/" to get around this, but what you have done works too. I've fallen into this trap more than once.
- Phil