Productivity negated by blogging
Monday, May 31st, 2010The Linux command line is incredibly powerful. It can control pretty much any aspect of your Linux system with only a few keystrokes, and can help automate and simplify repetitive tasks. For example, I’ve been working on a project for a magazine publisher recently, and one of the sections in their new website is a “back issues” area where subscribers can download, erm, back issues. I’ve been given 26 PDF documents containing each edition of the magazine dating back to mid-2007 or so, and needed to generate a thumbnail of each magazine cover. Two ways of accomplishing this spring to mind:
1) Open each PDF document, take a screenshot, paste into the GIMP, resize and save. Repeat 25 more times.
2) Use ImageMagick:
for pdf in `ls *.pdf` do convert -resize 120x90 "$pdf[0]" images/`echo $pdf | sed 's/\.pdf$/.jpg/'` done
Using method 1, I expected it would have taken me around 20 minutes of mind-numbing boredom, repeating the same old steps and trying not to get distracted by reading Slashdot every few images.
Using method 2, the whole batch was completed in 7 seconds. This massive gain in productivity has unfortunately been completely negated by the fact that I felt compelled to document it in this very blog post.
Anyway, the point to this story is that I wanted to make a note of the fact that ImageMagick is able to extract individual pages from a PDF document: the “[0]” part of “$pdf[0]” in the example above specifies use the first frame/page of the PDF document.