ImageMagick: Generating thumbnail from Page 2 of PDFs

Every single one of my PDFs has a disclaimer as its first page, making the default thumbnail generation less than useful. The easy solution to this is to tell IM to use page 2 instead of page 1, and the obvious place to do that is to change "[0]" to "[1]" in line 160 of /app/omeka/application/libraries/Omeka/File/Derivative/Image/Creator.php


private function _createImage($origPath, $newPath, $convertArgs)
{
$cmd = join(' ', array(
escapeshellcmd($this->_convertPath),
escapeshellarg($origPath . '[0]'), // first page of multi-page images.
$convertArgs,
escapeshellarg($newPath)
));

Unfortunately, I am strictly prohibited from modifying the base code, and the Derivative Images plug-in doesn't cover the thumbnail source.

Any suggestions?

If I copy Creator.php to my theme folder, will Omeka use my custom version instead of the installed version? I'm guessing not, since most theme-editable files live in views, but figured it was worth asking.

Sadly your suspicion is correct, you can't specify a different Creator somewhere without simply overwriting ours. A swappable Creator class isn't difficult and would enable some interesting things as well as workarounds like these, but it's just not set up that way.

Even just switching the 0 for a 1 is a little tricky, since ImageMagick croaks on non-multi-page files if you use anything but [0].

If you're absolutely restricted from editing the core, then the only thing I can think of is a plugin that essentially duplicates the Creator and does the thumbnail work itself, with a hook attached to the before/after save or ingest event.

Combined with blanking out the core ImageMagick path setting (disabling default thumbnail creation), you should be able to effectively "replace" our thumbnail creator in an roundabout ersatz fashion. Obviously that's not an optimal route, but it's something.

Bummer. I suppose for now I'll just change the number when I load content and hope no one pays attention to the last modified date. Luckily (in this context, anyway) the disclaimer prevents anything from being a single page.