3

How can I create a thumbnail from a photo or a video with the standard OS X tools? I mean, Finder is able to do it, so (being a Linux user), I expect to be able to do exactly the same without the GUI; is it possible?

3 Answers 3

7

It's far from perfect however you can use the save the thumbnail that Quick Look generates in the Finder by running the following command:

qlmanage -ti /PATH/TO/VIDEO_FILE.ext -o /PATH/TO/SAVE/PNG/TO

By default this produces a 128x128 png. Removing the i in the -ti will give you a PNG with the same aspect ratio as the video with the longest side being 128px.

To make it larger add the -s option or the -f option:

#512px version of the Finder icon
qlmanage -ti /PATH/TO/VIDEO_FILE.ext -s 512 -o /PATH/TO/SAVE/PNG/TO

#2.0 scaled version aka 256px
qlmanage -ti /PATH/TO/VIDEO_FILE.ext - 2.0 -o /PATH/TO/SAVE/PNG/TO

If you want better results (eg. choose your frame) I recommend using MacPorts to install ffmpeg or ImageMagick. (See fideli's answer)

2
  • great, although it's not very conveniant to specify a path and not directly the file name, that's exactly what I was looking for!
    – Kevin
    Jul 11, 2010 at 19:20
  • @Kevin: If you're in the same folder on the command line you don't need to use full paths.
    – Chealion
    Jul 11, 2010 at 20:12
2

To expand on www.haykranen.nl's post, install ffmpeg and ImageMagick using MacPorts.

For pictures, create a thumbnail using (i.e. fits within 250x90):

convert -thumbnail 250x90 in.png out.png

More info here.

For movies, create a thumbnail using:

ffmpeg -ss 00:09:00 in.avi -vcodec png -vframes 1 -an \
-f rawvideo -s 119x64 out.png

or

ffmpeg -ss 00:09:00 in.avi -vcodec mjpeg -vframes 1 -an \
-f rawvideo -s 119x64 out.jpg

where -ss 00:09:00 represents the point you want to take the thumbnail from (i.e. starting time), -vcodec represented here for either a PNG or JPEG, and -s is for the final size of the thumbnail. More info here.

Unfortunately, these tools aren't standard OS X tools. Your suggestion about how Finder is able to do it likely happens through a QuickTime or CoreVideo method that isn't easily accessible at the command line.

3
  • Quick Look (how Finder does it) is available on the command line :-)
    – Chealion
    Jul 11, 2010 at 4:41
  • Ah, learned something new!
    – fideli
    Jul 11, 2010 at 14:30
  • Thanks for this answer as well, it will be useful to get a more powerfull tool! is there anyway to take the screenshot at a random time of the video?
    – Kevin
    Jul 11, 2010 at 19:22
0

I'm not sure if there's a native command available for that, but you could always try installing ffmpeg from MacPorts, or alternatively (for photos), ImageMagick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .