php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64413 $pic->identifyImage() or $pic->getNumberImages return pages from PDF
Submitted: 2013-03-12 14:03 UTC Modified: 2013-10-15 11:54 UTC
From: tomse at tomse dot dk Assigned:
Status: No Feedback Package: imagick (PECL)
PHP Version: 5.3.22 OS: FreeBSD
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-03-12 14:03 UTC] tomse at tomse dot dk
Description:
------------
In some cases, PDF pages aren't properly detected when running getNumberImages
in this example there should be 34 pages, but Imagick says there is only 1. 

I'm in doubt if getNumberImages should count PDF pages.

if you run "identify delta.pdf" from the shell it lists all the pages with alot of info, on each new line.

but the output of Imagick::identifyImage is the closest I can come to the identify command.

A workaround hack would be to call exec("identify $x") but isn't the best solution.

A solution would be to either improve one of the two functions, or create a new one, Imagick::getNumberPages 


I've added som examples on how output could be below

Test script:
---------------
Example PDF file (save as delta.pdf)

http://www.roms4droid.com/manuals/PC%20Games/Manuals%20%28USA%29/D-F/Delta%20Force%204%20-%20Task%20Force%20Dagger%20-%20Mission%20Editor%20Manual.pdf


<?php
$f = "delta.pdf"; 

$pdf = new Imagick($f);
var_dump($pdf->getNumberImages());
var_dump($pdf->identifyImage());
?>

Expected result:
----------------
int(34)

array(9) {
  ["imageName"]=>
  string(10) "/delta.pdf"
  ["format"]=>
  string(30) "PDF (Portable Document Format)"
  ["geometry"]=>
  array(2) {
    ["width"]=>
    int(612)
    ["height"]=>
    int(792)
  }
  ["resolution"]=>
  array(2) {
    ["x"]=>
    float(72)
    ["y"]=>
    float(72)
  }
  ["units"]=>
  string(9) "Undefined"
  ["type"]=>
  string(14) "TrueColorAlpha"
  ["colorSpace"]=>
  string(4) "sRGB"
  ["compression"]=>
  string(9) "Undefined"
  ["fileSize"]=>
  string(7) "3.203MB"
  ["numberPages"]=>
  int(32)

}


Actual result:
--------------
int(1)
array(9) {
  ["imageName"]=>
  string(10) "/delta.pdf"
  ["format"]=>
  string(30) "PDF (Portable Document Format)"
  ["geometry"]=>
  array(2) {
    ["width"]=>
    int(612)
    ["height"]=>
    int(792)
  }
  ["resolution"]=>
  array(2) {
    ["x"]=>
    float(72)
    ["y"]=>
    float(72)
  }
  ["units"]=>
  string(9) "Undefined"
  ["type"]=>
  string(14) "TrueColorAlpha"
  ["colorSpace"]=>
  string(4) "sRGB"
  ["compression"]=>
  string(9) "Undefined"
  ["fileSize"]=>
  string(7) "3.203MB"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-25 07:52 UTC] mkoppanen@php.net
-Status: Open +Status: Feedback
 [2013-09-25 07:52 UTC] mkoppanen@php.net
getNumberImages gives me 34 on this PDF. Might be ImageMagick / Ghostscript 
version difference?
 [2013-10-15 11:54 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC