Bug 1369984

Summary: gscan2pdf v1.3.8 saves imported PDF pages as negative images
Product: [Fedora] Fedora Reporter: bob <redzilla.coralnut>
Component: gscan2pdfAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: bjohnson, ppisar, rakesh.pandit, sven
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: https://sourceforge.net/p/gscan2pdf/bugs/231/
Whiteboard:
Fixed In Version: gscan2pdf-1.5.2-2.fc26 gscan2pdf-1.5.2-2.fc25 gscan2pdf-1.3.9-2.fc24 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-10 17:46:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1378891, 1378895    
Bug Blocks:    
Attachments:
Description Flags
test case 1 - single page scanned and saved
none
test case 2 - same document, another page scanned. old image reversal. none

Description bob 2016-08-25 01:47:21 UTC
Description of problem:

I am using gscan2pdf v. 1.3.8 with a HP ScanJet ADF scanner.  The software scans new pages properly.  It has a problem, however, in appending newly scanned pages to a previously scanned document.  I open the software and use the File > Open menu to select a PDF file to import.  The PDF file was created with a previous version of gscan2pdf on F23.  I have since performed a clean bare metal install of F24 including gscan2pdf v1.3.8.  

gscan2pdf appears to properly import the existing pages from the old PDF.  All images appear normal.  

gscan2pdf appears to properly scan several new pages.  All page images appear normal.  

All pages are then saved by clicking on the "Select All Pages" button, and then clicking the "Save" button.  During the save, I request to over-write an existing file.  The save process appears to proceed normally ... until the PDF file is opened for viewing.  

Okular is automatically used to display the newly created PDF file (I am using the KDE spin).  When the PDF is opened, all pages appear as a negative image.  ie: scanned pieces of paper that were imported from the old PDF, which should appear as black lettering on white text, appear as white lettering on black text, while the newly scanned pages appended to the document during the last scanning run appear properly as black type on white paper.

If this process is repeated, all of the imported images look fine during use of the program, and new images can be scanned.  Everything looks normal during use of the program, but after a save, all of the pages imported from the old PDF are now rendered as negative images, and only those from the most recent scan event are rendered as positive images.  Somehow during the save, the old images are having their B&W color scheme reversed.



Version-Release number of selected component (if applicable):

gscan2pdf v1.3.8

How reproducible:

Always

Steps to Reproduce:
1. Import an old pdf
2. Append newly scanned pages
3. Everything looks fine.
4. Save
5. View new pdf file, and all of the imported images are white on black, while all of the newly scanned images are black on white.

Actual results:

Negative reversal of imported B&W images from previous PDF occurs during save.

Expected results:

No reversal of image color.

Additional info:

None.

Comment 1 bob 2016-08-25 01:49:59 UTC
Previous description has a typo.  the last 2 paragraphs should read as follows:


Okular is automatically used to display the newly created PDF file (I am using the KDE spin).  When the PDF is opened, all pages appear as a negative image.  ie: scanned pieces of paper that were imported from the old PDF, which should appear as black lettering on white background, actually appear as white lettering on black background, while the newly scanned pages appended to the document during the last scanning run appear properly as black type on white background.

If this process is repeated, all of the imported images look fine during use of the program, and new images can be scanned.  Everything looks normal during use of the program, but after a save, all of the pages imported from the old PDF are now rendered as negative images, and only those from the most recent scan event are rendered as positive images.  Somehow during the save, the old images are having their B&W color scheme reversed.

Comment 2 bob 2016-08-25 03:11:42 UTC
Created attachment 1193854 [details]
test case 1 - single page scanned and saved

test case 1 - single page scanned and saved

Comment 3 bob 2016-08-25 03:13:00 UTC
Created attachment 1193855 [details]
test case 2 - same document, another page scanned.  old image reversal.

test case 2 shows what happens when an existing pdf is imported, a new page is scanned, and the document saved.  the original document has it's image reversed when the new document is saved.

Comment 4 Petr Pisar 2016-08-31 14:31:24 UTC
Thank you for the detailed description. I can reproduce it.

Comment 5 Petr Pisar 2016-08-31 15:07:50 UTC
I think it's caused by some change in other packages upgraded between Fedora 23 and 24. The simplest reproducer is importing a PDF and then saving it.

Comment 6 Petr Pisar 2016-09-23 11:56:48 UTC
So far I found one bug and one difference.

When storing saving to PDF, gscan2pdf converts all pages from PNG into TIFF and the again from TIFF to TIFF and that writes the TIFF images into PDF.

The difference is somewhere in the conversion between the PNG and the second TIFF. Fedora 23 produces 1bpp TIFF, while Fedora 24 produces 8bpp TIFF.

The bug is PDF::API2 used for writing TIFF into PDF mishandles the 8bpp TIFF and produces a PDF with broken image. This happens on Fedora 23 and 24, but it's visible only on Fedora 23 as there is the 8bpp TIFF.

Comment 7 Petr Pisar 2016-09-23 11:58:29 UTC
s/visible only in Fedora 23/visible only on Fedora 24/.

Comment 8 Petr Pisar 2016-09-23 12:42:24 UTC
The difference is in converting 1bpp PNG into TIFF by Image::Magick. Fedora 23 produces 1bpp TIFF, Fedora 24 produces 8bpp TIFF.

Comment 9 Petr Pisar 2016-09-30 14:42:58 UTC
I applied an workaround until ImageMagick will be fixed.

Comment 10 Fedora Update System 2016-09-30 20:23:08 UTC
gscan2pdf-1.5.2-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-14e8e1583d

Comment 11 Fedora Update System 2016-10-01 05:27:23 UTC
gscan2pdf-1.3.9-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-6d7dcc529f

Comment 12 Fedora Update System 2016-10-10 17:46:01 UTC
gscan2pdf-1.5.2-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2016-10-10 21:49:36 UTC
gscan2pdf-1.3.9-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.