You are here

function pdf_to_image_exec in PDF to ImageField 7.2

Convert a PDF to an image, using ImageAPI.

1 call to pdf_to_image_exec()
pdf_to_image_generate_page in ./pdf_to_image.module
Generate a single page for the given pdf file.

File

./pdf_to_image.module, line 601
Implement a pdf field, based on the file module's file field.

Code

function pdf_to_image_exec($source, $dest, $args = array(), $extra = array()) {
  $convert_path = variable_get('imagemagick_convert', '/usr/bin/convert');
  $args['quality'] = '-quality ' . escapeshellarg(variable_get('imagemagick_quality', 75));
  $command = implode(' ', $extra) . ' ' . escapeshellarg($source) . ' ' . implode(' ', $args) . ' ' . escapeshellarg($dest);
  if (_imagemagick_convert_exec($command, $output, $errors) !== TRUE) {
    $errors_txt = '<pre>' . (is_array($errors) ? implode("\n", $errors) : $errors) . '</pre>';
    watchdog('pdf to image: imageapi imagemagick', '!errors', array(
      '!errors' => $errors_txt,
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return file_exists($dest);
}