2

It appears that macOS now generates preview images for certain files (notably RAW image files) that are not custom icons but something else. (You can toggle them on/off in latish model macOS via "show icon preview" in Finder window "Show View Options".)

I'd love to be able to either obtain these images or use the API that generates them but I'm obviously googling the wrong terms. The usual APIs will get me the file icon (which is usually a generic document icon) and not the preview. The tricks for getting custom icons (e.g. .DS_Store etc.) do not apply.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
podperson
  • 2,284
  • 2
  • 24
  • 24
  • @rmaddy I don't think the tag changes are correct since the QuickLook framework is accessible via Swift / Obj-C. – podperson Apr 24 '18 at 19:39
  • But your question has nothing to do with either language. The answer you accepted make no use of either language. – rmaddy Apr 24 '18 at 19:56
  • But I would love to have received a detailed answer showing, for example, how to use the [QuickLook](https://developer.apple.com/documentation/quicklook) framework using either language, and someone who codes in said languages won't see the question because of your edit. Similarly, someone who codes in Swift of Obj-C who wants to know which framework is involved won't find the answer as easily. – podperson Apr 24 '18 at 20:23
  • I'm also guessing that @rob-napier wouldn't have seen my question without the tags it had on it. – podperson May 17 '18 at 20:21

2 Answers2

5

The tool you want is qlmanage. In particular, look at qlmanage -t (thumbnail) and qlmanage -p (preview). By default, it opens a viewer for you. If you want to generate files to process yourself, see the -o option. For example:

qlmanage -t image.png -o .

This will create a thumbnail file called ./image.png.png (it attaches .png to whatever the filename is).

If you want to build your own tools around this, see the QuickLook framework.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
1

A little more info w.r.t. using QuickLook framework. The key method is QLThumbnailImageCreate (QuickLook previews are PDFs which are not what I want and likely not what someone doing something similar wants).

Even though the function name indicates that it creates thumbnails, it can create an image of any size (and the size parameter dictates a maximum dimension).

podperson
  • 2,284
  • 2
  • 24
  • 24