Print Page | Close Window

image extraction questions

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1333
Printed Date: 25 Dec 25 at 1:55AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: image extraction questions
Posted By: sobisch
Subject: image extraction questions
Date Posted: 02 Feb 10 at 7:50AM

Here my little Script for extract Images of a PDF in PHP:

 
qp->LoadFromFile($path_to_pdf.'test.pdf');
$imagecount = $qp->FindImages();
if ($imagecount>0) {
 for ($image = 1; $image <= $imagecount; $image++) {
  $imageid = $qp->GetImageID($image);
  $qp->SelectImage($imageid);
  switch ($qp->ImageType()) {
   case 1: $imagetype = "jpg"; break;
   case 2: $imagetype = "bmp"; break;
   case 3: $imagetype = "tif"; break;
  }
  $qp->SaveImageToFile($path_to_pdf."image".$image.".".$imagetype);
 }
}
 
I tried this with a PDF with 2 pages, and 7 Pictures (all .bmp)
 
The Problem is, that the saved Images are partly incorrect in the Colors. All 7 images are drawings on white Background. But 4 of the saved images has reversed Colors :/ So The Background is Black and the Lines are white. So of course I can use a image library to revert the Colours of the Image, but how is it possible to find out which images have correct Colours and which does not? Of course I want save all Images of the PDF in the correct Colour ;)
 
I tried a small shell program (pdfimages.exe) to extract the Images from the same pdf. With this program, all Images have the correct Colour, so it had to be possible to get the correct Colours width QuickPDF, too?
 
And another question: On the first page of the PDF are 5 pictures, on the second page are 3 pictures. How can I extract the Page Number of the Images, or Extract only the Images of the Current Page? I need the assignment between pages and images.



Replies:
Posted By: sobisch
Date Posted: 02 Feb 10 at 12:39PM
PS: the DARenderPageToFile() has the same Problem :)
 
I generate a image of each page of the PDF file. In this page-preview, the 4 images have reversed colours, too... So there are white lines on black background, the original Image (as the pdf viewer displays ist) has black lines on white background...
 
Has anyone similar problems with the Image Funktions of quickpdf?



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk