Test "kind" string shown in Finder for a file (e.g. "PNG image")

If you open a folder in list view in Finder, one of the columns is headed “Kind” and contains strings like “Document,” “PNG image,” etc. I would like to be able to test whether a file has a “Kind” string that contains the substring “image,” but I can’t figure out how to do this.

I see that the file type of a TIFF file is “TIFF” - but how can I test for “TIFF image” (or “PNG image”, etc.).

Many thanks for any help with this.

EDIT: I realize that what I’m asking for is a way to do in AppleScript something like what Automator does when it lets you filter Finder items by “Kind is image”, etc.

That’s a pretty rough way to try find images, and it’s likely to fail on non-English systems. Here’s an alternative that I suspect does what you want:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set {theResult, theUTI} to theURL's getResourceValue:(reference) forKey:(current application's NSURLTypeIdentifierKey) |error|:(missing value)
set isImage to current application's NSWorkspace's sharedWorkspace()'s |type|:theUTI conformsToType:"public.image"

Edited: Added “POSIX path of”

Thank you yet again, Shane (something I keep saying over and over). When I run this, I get this error message:

-[NSURL length]: unrecognized selector sent to instance 0x6000008bd0a0

This happens if I run it as a script or as an application. Am I missing something obvious?

No, I was. It should work now.

Thank you, Shane! That works, though (for the sake of anyone else who uses this) “choose file” needs to be in parentheses for Script Debugger to run it.