ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: captured on October 29, 2018, 08:12:45 PM

Title: Adobe .psd is not recognized as an image with -mimetype
Post by: captured on October 29, 2018, 08:12:45 PM
Hello.

Existing exiftool code to only output if;

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
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: Phil Harvey on October 31, 2018, 06:34:44 AM
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
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: captured on October 31, 2018, 11:32:04 AM
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.
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: Phil Harvey on October 31, 2018, 11:43:51 AM
I think you need some brackets in there to force the correct order of evaluation (the "or" operator is super-low precedence).

- Phil
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: captured on October 31, 2018, 11:46:25 AM
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.
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: Phil Harvey on October 31, 2018, 11:50:52 AM
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
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: captured on October 31, 2018, 11:57:56 AM
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.
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: captured on November 01, 2018, 10:39:29 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]
Title: Re: Adobe .psd is not recognized as an image with -mimetype
Post by: Phil Harvey on November 01, 2018, 11:02:14 AM
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