[Koha-bugs] [Bug 13954] Patroncards: images show inadequate rough pixelation

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Apr 6 20:48:49 CEST 2015


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13954

--- Comment #9 from Marc Véron <veron at veron.ch> ---
Chris, thank you very much for your comment.

There is an example for scaling images in PDF Reference:

http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_1-7.pdf


Page 339, Example 4.72
% = comment

---snip--- 
  q                                        % Save graphics state
  1 0 0 1 100 200 cm                       % Translate
  0.7071 0.7071 −0.7071 0.7071 0 0 cm      % Rotate [not yet used in our case,
MV]
  150 0 0 80 0 0 cm                        % Scale
  /Image1 Do                               % Paint image
  Q                                        % Restore graphics state
---snip---

- Translate puts the image at a given position
- Rotate is not used at in Patroncard.pm (but could be used at a later stage)
- Scale (new line in Patroncard.pm) does what it says (it does not shrink the
image data, however, it scales it).
- The Do operator paints the image using the transformation rules above.

Page 206 (Chapter 4.2 Coordinate Systems -> 4.2.2. Common Transformatons) says:
---snip---
If several transformations are combined, the order in which they are applied is
significant. For example, first scaling and then translating the x axis is not
the same as first translating and then scaling it. In general, to obtain the
expected results, transformations should be done in the following order:
1.Translate
2.Rotate
3.Scale or skew
---snip---

On the same page is a figure that shows the big differences in the result if
you apply the transformations in different sequences.

In our case the issue was that the image was downsampled / shrinked to a very
small size (using ImageMagick) before it was applied to the PDF. The resulting
image had (in my test case) a height of about 70 units (pixels). The quality
was like (or even less) the quality of a thumbnail picture. The PDF viewer then
had to scale it up for displaying or printing - that's why it looked so
'pixelated'. If the picture has a height of 350 units (pixels) and is
transformed down to 70 while preparing it for the display it, the result is
much better, simply because we have more image data available.

In short, the steps are:
- Prepare a normalized jpg image with a good quality / size using ImageMagick
- Position this image on the PDF page (Translate)
- (Rotate /chew it if necessary, we don't do it here)
- Scale it down to the final display size

PS: I can imagine some sophisticatd enhancements as well. 
For example, it would be nice to have the possibility to put an image as
background or to rotate an image etc., with appropriate parameters in the UI.
But that would not be in the scope of this Bug.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list