Getting an image file's dimensions

Mikuro

Crotchety UI Nitpicker
Can anyone recommend a fast way to get the width and height of an image file in Cocoa? AppleScript would work, too, I suppose.

I'm creating a screen saver that displays pictures, and I want to fill the screen with as many images as possible (without any cropping and with minimum scaling). This means I need to know the aspect ratios of every image at my disposal so I can pick which ones to load.

Right now I load every file in turn into an NSImage just long enough to store its width and height, but this is awfully slow.

I think the Finder does this when you have the "Show item info" view option checked, but I don't know how. Any ideas?
 
Back
Top