← Back to team overview

pkg-perl-maintainers team mailing list archive

[Bug 1063198] Re: Inverse colors when converting png -> pdf

 

For me, unchecking downsampling option is also a workaround. It seems
that libpdf-api2-perl doesn't like

convert -depth 8 -resize 516x730 input.png input.tif

Then the script below with PDF::API2 produces the inverted colours.

input.png[1] PNG 2481x3508 2481x3508+0+0 8-bit PseudoClass 256c 226KB 0.000u 0:00.000
input.tif[2] TIFF 516x730 516x730+0+0 8-bit DirectClass 228KB 0.000u 0:00.000

Without the -resize option, the colours are fine.

input.png[1] PNG 2481x3508 2481x3508+0+0 8-bit PseudoClass 256c 226KB 0.000u 0:00.009
input.tif[2] TIFF 2481x3508 2481x3508+0+0 8-bit PseudoClass 256c 239KB 0.000u 0:00.000

So it looks as though libpdf-api2-perl doesn't like DirectClass TIFFs:

convert -depth 8 -resize 516x730 -type palette input.png input.tif

input.tif TIFF 516x730 516x730+0+0 8-bit PseudoClass 256c 93.5KB 0.000u
0:00.000

And yes - the colours are then correct.

#!/usr/bin/perl -w
use strict;
use PDF::API2;
use Image::Magick;
my $pdf = PDF::API2-> new(-file => 'test.pdf');
my $image    = Image::Magick->new;
$image->Read('input.tif');
my $resolution = $image->Get('x-resolution');
my $w          = $image->Get('width') / $resolution;
my $h          = $image->Get('height') / $resolution;
my $page = $pdf->page;
$page->mediabox( $w * 72, $h * 72 );
my $gfx = $page->gfx;
my $img = $pdf->image_tiff($tiff);
$gfx->image( $img, 0, 0, $w * 72, $h * 72 );
$pdf->save;
$pdf->end;


** Package changed: gscan2pdf (Ubuntu) => libpdf-api2-perl (Ubuntu)

-- 
You received this bug notification because you are a member of Debian
Perl Group, which is subscribed to libpdf-api2-perl in Ubuntu.
https://bugs.launchpad.net/bugs/1063198

Title:
  Inverse colors when converting png -> pdf

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/libpdf-api2-perl/+bug/1063198/+subscriptions