Skip Menu |
 

This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics
Id: 29366
Status: resolved
Priority: 0/
Queue: PDF-API2

People
Owner: Nobody in particular
Requestors: stefan.scherer [...] sealsystems.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.55
Fixed in: (no value)



Subject: reading TIFF resolution does not work for pixel/cm
Download (untitled) / with headers
text/plain 648b
I'm using PDF::API2 0.55 at the moment and want to read the TIFF resolution to paint the TIFF in its original size onto the PDF page. But I found out that the TIFF resolution is always interpreted as Pixel/Inch. The TIFF also has another TIFF-Tag to set the unit for resolutions. I have a TIFF with Pixel/cm set. The value read by PDF::API2 is then wrong. The attached test file 1x1cm.tif is generated with 400 pixel/inch which is 157 pixel/cm. Solution: Also read TIFF tag 296. If it has value 3, then the ResolutionUnit is Pixel/cm. After reading all TIFF Tags then correct the xRes and yRes values to have them as Pixel/Inch again.
Subject: 1x1cm.tif
Download 1x1cm.tif
image/tiff 27.7k
1x1cm.tif
From: stefan.scherer [...] sealsystems.de
Download (untitled) / with headers
text/plain 928b
The patch in CVS works fine. Here is my current code to read TIFF's and keep the original size on PDF. This code now works for dpi and pixel/cm. $rasterImage=$pdf->image_tiff($image); ... my $w = $rasterImage->width; my $h = $rasterImage->height; if ($Type eq "TIFF") { my $xRes = $rasterImage->tiffTag('xRes') || 0; my $yRes = $rasterImage->tiffTag('yRes') || 0; my $resUnit = $rasterImage->tiffTag('resUnit') || 2; if ($resUnit == 3) { # pixel/cm $xRes = $xRes * 2.54; $yRes = $yRes * 2.54; } if ($xRes > 0 && $w > 0) { $w = $w * 72 / $xRes; } if ($yRes > 0 && $h > 0) { $h = $h * 72 / $yRes; } } ... $gfx->image($rasterImage,$l,$b,$w,$h);
released


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.