function pdf_to_imagefield_convert_pdf in PDF to ImageField 6.2
Same name and namespace in other branches
- 6 pdf_to_imagefield.module \pdf_to_imagefield_convert_pdf()
- 7 pdf_to_imagefield.module \pdf_to_imagefield_convert_pdf()
Convert a PDF to an image, using ImageAPI.
This is almost a copy of _imageapi_imagemagick_convert() function, with that addition of $extra argument, used to pass parameters to convert *BEFORE* source file specification. Here it is needed to set density before rendering a PDF.
Return value
bool success
3 calls to pdf_to_imagefield_convert_pdf()
- pdf_to_imagefield_check_imagemagick in ./
pdf_to_imagefield.module - Helper function to check if ImageMagick is ready to convert
- pdf_to_imagefield_convert_pages in ./
pdf_to_imagefield.module - Convert pages from pdf file to individual jpeg files
- pdf_to_imagefield_generate_page in ./
pdf_to_imagefield.module - Generate a single page for the given pdf file-source, according to the field settings.
File
- ./
pdf_to_imagefield.module, line 115 - PDF to ImageField core hooks and menu callbacks.
Code
function pdf_to_imagefield_convert_pdf($source, $dest, $args = array(), $extra = array()) {
$d_arguments['quality'] = '-quality ' . escapeshellarg(variable_get('imageapi_imagemagick_quality', 75));
// To make use of ImageMagick 6's parenthetical command grouping we need to make
// the $source image the first parameter and $dest the last.
// See http://www.imagemagick.org/Usage/basics/#cmdline for more info.
$command = implode(' ', $extra) . ' ' . escapeshellarg($source) . ' ' . implode(' ', $args) . ' ' . escapeshellarg($dest);
if (0 != _imageapi_imagemagick_convert_exec($command, $output, $errors)) {
$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);
}