You are here

function pdf_to_imagefield_count_pages in PDF to ImageField 7

Same name and namespace in other branches
  1. 6.2 pdf_to_imagefield.module \pdf_to_imagefield_count_pages()

Use imagemagick routine to count the number of pages in a given PDF

1 call to pdf_to_imagefield_count_pages()
pdf_to_imagefield_set_batch in ./pdf_to_imagefield.module
Prepare the batch job to process a PDF file.

File

./pdf_to_imagefield.module, line 374
PDF to ImageField core hooks and menu callbacks.

Code

function pdf_to_imagefield_count_pages($filepath) {

  // We can guess that if inmagemagick is installed, the identify function mst be close to it
  $convert_path = variable_get('imageapi_imagemagick_convert', '/usr/bin/convert');
  $identify_path = dirname($convert_path) . '/identify';
  $command = "{$identify_path} -format %n " . escapeshellarg($filepath) . ' 2> /dev/null';
  $count = shell_exec($command);
  return $count;
}