anyone use Matt Gemmell's NSImage+QuickLook to QuickLook at images

I’m having a problem (the answer to which I’m sure will, as usual, be obvious to everyone but me :slight_smile: )

I’ve added the QuickLookUI.Framework and Matt’s .h and .m files, and here’s the relevant bit of my code:

				set imagePath to POSIX path of (item i of mfilePaths)
				log imagePath
				set theSize to {|width|:190, height:190}
				log "theSize"
				log theSize
				set newImage to imageWithPreviewOfFileAtPath_ofSize_asIcon_(imagePath, theSize, YES)
				--imageWithPreviewOfFileAtPath:(NSString *)path ofSize:(NSSize)size asIcon:(BOOL)icon
				imageView's setImage_(newImage)

and the debugger console shows

2010-04-06 13:28:18.114 jKeyword[29547:a0b] /Users/rhb/Desktop/testpics/789-4371-io-son-038.cr2
2010-04-06 13:28:18.115 jKeyword[29547:a0b] theSize
2010-04-06 13:28:18.115 jKeyword[29547:a0b] {
height = 190;
width = 190;
}
2010-04-06 13:28:18.124 jKeyword[29547:a0b] *** -[jKeywordAppDelegate imageWithPreviewOfFileAtPath:ofSize:asIcon:]: unrecognized selector sent to object <jKeywordAppDelegate @0x2000d3460: OSAID(13)>
2010-04-06 13:28:18.126 jKeyword[29547:a0b] *** -[jKeywordAppDelegate table2Clicked]: *** -[jKeywordAppDelegate imageWithPreviewOfFileAtPath:ofSize:asIcon:]: unrecognized selector sent to object <jKeywordAppDelegate @0x2000d3460: OSAID(13)> (error -10000)

Any thoughts?

Thanks

rhb

I can’t see imageWithPreviewOfFileAtPath_ofSize_asIcon_ anywhere in help, but in that snippet it looks like you’re not actually calling it on anything (except your script itself, by default).

it’s being called through
myTableView2’s setAction_(“table2Clicked”)
which calls the script.

The problem is that I originally just got the thumbnail of the image files I’m working with.

set output to do shell script ("exiftool -b -ThumbnailImage " & quoted form of ((item i of mfilePaths) as text) & " > " & quoted form of (FILE_PATH & "/TMP.JPG"))
set imagePath to (FILE_PATH & "/TMP.JPG")
set newImage to NSImage's alloc()'s initWithContentsOfFile_(imagePath)
imageView's setImage_(newImage)

Bit clunky, but it worked.

Then I discovered that most of the files don’t have a thumbnail (they come from professional photo studios—Canon, Nikon, Hasselblad, sinar etc cameras and software)

So I’m trying the QuickLook stuff.

The instructions for NSImage+Quicklook are:

The error it generates “unrecognized selector sent to object” suggests that I’m not passing the right path, size or BOOL. but I can’t see wherein they are wrong.

rhb

No, it’s being called on the wrong object. What you posted says that imageWithPreviewOfFileAtPath_ofSize_asIcon_ is a class method of NSImage, whereas you’re calling it as if its an instance method of your AS class.

So you need to change this:

               set newImage to imageWithPreviewOfFileAtPath_ofSize_asIcon_(imagePath, theSize, YES)

into this:

               set newImage to current application's NSImage's imageWithPreviewOfFileAtPath_ofSize_asIcon_(imagePath, theSize, YES)

Perfect! It works!!

Thanks Shane!

I take solace from the fact that I did call the solution as being obvious to you

:smiley:

rhb