function pdf_to_image_shell_exec in PDF to ImageField 7.3
Run the given command (expected to be an imageMagick Commandline).
Wrapped in a bugfix workaround.
Parameters
string $command: Command to execute.
Return value
string the shell response
3 calls to pdf_to_image_shell_exec()
- pdf_to_image_check_imagemagick in ./
pdf_to_image.module - Check the binary path of 'convert' on the server.
- pdf_to_image_convert_exec in ./
pdf_to_image.module - Actually execute the shell command.
- pdf_to_image_count_pages in ./
pdf_to_image.module - Use imagemagick routine to count the number of pages in a given PDF.
File
- ./
pdf_to_image.module, line 786 - Generates thumbnail image(s) from an uploaded PDF.
Code
function pdf_to_image_shell_exec($command) {
// Horrible bug. If running on Acquia dev desktop, it sets a custom path for
// the dynamic link library. But 2012-04 that was OLDER than the libraries
// My OS expected to use to run graphics utilities with.
// Reason: Incompatible library version:
// dot requires version 10.0.0 or later,
// but libltdl.7.dylib provides version 9.0.0
// UNSET the Acquia DYLD_LIBRARY_PATH before dropping to commandline to run.
$dyld_library_path = getenv("DYLD_LIBRARY_PATH");
putenv("DYLD_LIBRARY_PATH=");
// This looks like a no-op, but it's actually sometimes neccessary
// (maybe just under dev desktop)
// in order to allow gs to be found! Mad.
putenv('PATH=' . getenv('PATH'));
watchdog('pdf_to_image', 'Running commandline %command', array(
'%command' => $command,
), WATCHDOG_DEBUG);
// Capture error output in the response as well.
$response = shell_exec($command);
// Put it back just in case it matters.
putenv("DYLD_LIBRARY_PATH={$dyld_library_path}");
return $response;
}