How to make good jpeg previews for pdf, psd & mov on the command line.
Yes you did read that right: preview images for photoshop, quicktime and pdf.
Like so many web developers I need to make a jpeg/gif/png preview of photoshop files, and quicktime and pdfs.
We need thumbnails for these things and I mean NEED.
First the bad news, this will only work on OS X 10.4.
I will be trying to find a way to make it work on FreeBSD.
Now the good news.
ImageMagick needs Ghostscript to make images of PDF's and a quick read of the forum indicates they're not all that great.
ImageMagick can also make previews of photoshop files but my tests using files created by real designers looked like a bombsite. No good.
ImageMagick doesn't really acknowledge the existence of quicktime as a format so I couldn't even attempt that.
Thanks to a very demanding client I just kept looking for an answer, you know how it goes...
If I read every single page on the web I might find one. Once I've got to the end start again as a billion years have passed and surely things have changed by now.
So I read the forums trying to find a way to get the poster frame from quicktime and came across a mention of qt_tools.
Quicktime is a major part of the Mac OS and this explains what I'm about to show you.
Sadly Quicktime doesn't seem to have the ability to export as jpeg or any other browser readable format via the command line so you will probably still need ImageMagick.
If you're like me you will anyway as you'll want to resize etc.
First get qt_tools from:
<a href="http://www.omino.com/~poly/software/qt_tools/" target="_blank">http://www.omino.com/~poly/software/qt_tools/</a>
I have a rigourous installation process so I have the following folder on my test server:
/home/src/
I download all my sources into there, it makes it easy to keep track of things.
Some of my servers are on the other side of the world so I'll also show you how to do this without going anywhere near the finder.
open terminal and get ready to copy and paste, or if you're installing remotely open up your ssh session to your remote server and again get ready to copy and paste:
ready:
change into the directory you like to keep your source in: cd /home/src/
download the files using curl curl -O <a href="http://www.omino.com/~poly/software/qt_tools/qt_tools.tgz" target="_blank">http://www.omino.com/~poly/software/qt_tools/qt_tools.tgz`
untar them tar xzf qt_tools.tgz
now you'll have a folder starting with qt_tools in my case qt_tools_2_0_414, you'll want to cd into it: cd qt_tools_2_0_414
Read the readme etc because you're a dilligent developer who never ever pesters the poor creator of great tools like this before you've read stuff... do you.
Now you can build it: sudo ./install.sh
enter your admin pw to install when prompted
you'll be asked whether you really want to install:
Do you wish to install qt_tools? (y/n):
you probably do ;)
That's it install done. Easier than imagemagick right ;)
You'll need to have /usr/local/bin in your path in order to call the command directly without having to put the entire path in explicitly.
On bash you can do this like so:
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
Then you have to close and re-open the terminal window/ssh session.
Have a read of the help docs to see how to use the tools:
http://www.omino.com/~poly/software/qt_tools/man/qt_export.html
lets say you want to make a PICT from a frame in a quicktime movie: Lets say that frame is at 20.4 seconds.
qt_export --exporter=PICT,.... /xxx.mov /test.PICT --duration=20.4,20.4
Here's the magical bit, you'd expect it to do quicktime, it being called qt_tools, but as quicktime is such an integral part of the OS it can read all sorts of files.
If you don't believe me just try opening a photoshop file in quicktime and you'll see.
So to conver a psd to a pict we do:
qt_export --exporter=PICT,.... /psdtest.psd /psdtest.PICT --duration=0.0,20.4
How about a pdf:
qt_export --exporter=PICT,.... /pdftest.pdf /pdftest.PICT --duration=0.0,20.4
I'm sure there's loads of other formats it'll play with.