Problem/Motivation

The module does not support creating thumbnail for PDF with space in their filename.

Proposed resolution

When the command line to run ImageMagick is created, it needs to enclose the filename in ". This may be an issue with the ImageMagick module itself.

Initial report

Hello there,
I have been trying to get this configured for hours now with no success. I have the imageMagick library installed on the server and can get it to work from the command line, but every time i try to use it with the pdfPreview module i get:

User error: ImageMagick error 1: convert: no images defined `/var/www/youngforest.org/html/sites/default/files/pdfpreview/114-Young Forest Brochure 032513.jpg' @ error/convert.c/ConvertImageCommand/3187. in _imagemagick_convert_exec() (line 519 of /var/www/youngforest.org/html/sites/all/modules/imagemagick/imagemagick.module).

I don't know what i'm doing wrong to cause this error. Any help would be greatly appreciated.

Comments

code-drupal’s picture

The issue occurs because of spaces in the PDF filename. If you upload a PDF file without any spaces in the filename...it will work properly.

pbuyle’s picture

pbuyle’s picture

Issue summary: View changes
hctom’s picture

I have the same problem on Mac OSX. When copying the executed command to the shell it does not work, too. But when I remove the quotes added by escapeshellarg() function for the target image file path, it works from the shell - I know this is not an option, but somehow this seems to be more of a problem with convert command's argument handling, doesn't it?

ultrabob’s picture

I don't know if everyone facing this issue is facing it on a mac, but in my experience this error had nothing to do with whether there was a space in the filename. The issue for me was that ghostscript was not in Apache's path. In El Capitan, making changes to the $PATH variable that Apache uses seems to be next to impossible without disabling SIP. I worked around it by modifying the path in my settings.php.

r0nn1ef’s picture

I was experiencing this same issue in my dev environment in LinuxMint 17.3 with Apache 2.4.7 and PHP 5.5.9. When I unchecked the box for "Enable GraphicsMagick support" the problem appears to have gone away.

KarlShea’s picture

The issue for me was that ghostscript was not in Apache's path.

This was also what fixed the issue for me, spaces in the filename weren't a problem. I'm running Homebrew's PHP-FPM and I had to make sure /usr/local/bin was in env[PATH] in php-fpm.conf (mine was at /usr/local/etc/php/5.6).

Mschudders’s picture

My problem on MAC OSX was that I didn't have the ghost binary installed.

You can check this via:
which gs

if this doesn't return anything you can quickly install it via:
brew install ghostscript

on linux it should be:
apt-get install ghostscript

Cheers

firewaller’s picture

Turns out even though I installed imagemagick via Homebrew, I still needed to install ghostscript. I then realized that MAMP had both, so I switched my image toolkit convert binary path to: /Applications/MAMP/Library/bin/convert and everything started working!

impara’s picture

If you have the PHP imagick extension then change to that instead by doing:

$source = drupal_realpath($source);
$destination = drupal_realpath($dest);
$imagick = new Imagick();
// Reads image from PDF
$imagick->readImage($source);
// Writes an image or image sequence Example- converted-0.jpg, converted-1.jpg
return $imagick->writeImages($destination, false);
clairedesbois@gmail.com’s picture

I confirm #8, install ghostscript has solved the problem for me.