Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagetoraster, imagetopdf: Images do not get formatted correctly #145

Closed
tillkamppeter opened this issue Aug 25, 2019 · 8 comments
Closed

Comments

@tillkamppeter
Copy link
Member

I take a usual digital photo as it comes out of a camera, landscape orientation, 4;3 aspect ratio and pass it through the filter chain for printing, using a PPD of Dye Sublimation photo printer used with Gutenprint.
The command lines are as follows:

cupsfilter -P DS620.ppd -m application/vnd.cups-raster -o PageSize=w432h648 -o Resolution=300dpi P8235870.JPG > test-plain.raster
cupsfilter -P DS620.ppd -m application/vnd.cups-raster -o PageSize=w432h648 -o Resolution=300dpi -o fill P8235870.JPG > test-fill.raster
cupsfilter -P DS620.ppd -m application/vnd.cups-raster -o PageSize=w432h648 -o Resolution=300dpi -o fit-to-page P8235870.JPG > test-fit.raster

This is the PPD file
DS620.ppd
and this is the picture:
P8235870.JPG
To visualize the output files (CUPS Raster format) I use rasterview.
What I expect is that the picture gets rotated by 90 degrees as it is landscape and the output page is portrait. I also expect that after the rotation it gets scaled into the frame according to the selected option and scaled the same in X and Y direction, not stretched in one direction more than in the other. A square should stay a square.
Also the CUPS Raster header data about the page geometry (page sizes/dimensions, margins, bounding boxes) should match one the PPD's paper size entry (ImageableArea/PaperDimension) of the selected paper size and should also contain the size's name (in rasterview click the button at the lower right to display header data of the page).
The problems are the following:

  • imagetopdf (executable bit of imagetoraster removed, CUPS restarted, CUPS Raster headers are all correct here, but they are generated by gstoraster)
    • With the "fill" option (test-fill.raster) the image is NOT rotated before scaling to fill the page.
    • "fit-to-page" (test-fit.raster) works correctly.
    • No option (test-plain.raster) is like "fit-to-page" which is OK.
  • imagetoraster (standard installation/configuration of cups-filters)
    • With the "fill" option (test-fill.raster) the image is NOT rotated before scaling to fill the page (same as with imagetopdf). The CUPS Raster header is correct here.
    • "fit-to-page" (test-fit.raster) scales the rotated (correct) image to fit the paper width (correct) but does not add white areas at the top and the bottom. Instead, it adds larger unprintable margins in the CUPS Raster header. This is wrong and most probably makes the printer driver producing a wrong printout. The paper sizes/dimensions, margins, and bounding boxes have to match the selected page size's ("PageSize" option or default setting) entry in the PPD file (ImageableArea/PaperDimension keywords).
    • No option (test-plain.raster) is the same wrong behavior as "fit-to-page".

So the problems are the non-rotated image for the "fill" case with both imagetopdf and imagetoraster and the wrong CUPS Raster header with "fit-to-page" or no option in imagetoraster.

@dheeraj135, could you have a look into this? Thanks.

@dheeraj135
Copy link
Member

Ok. I will look into it.

@tillkamppeter
Copy link
Member Author

@dheeraj135, I have found the cause for the images not getting auto-rotated. You have used overly complicated ways to determine whether the image and the output page are of mismatching orientations (landscape/portrait). I have replaced the occurences by a simple, intuitive expression and it works now.
see my commit 41e5626 and commit ea696db.
Now only the page header problem of imagetoraster needs to be solved. Note that here also with "fill" and a borderless page size selected from the PPD the margins are not exactly zero. This is perhaps also a hint on what is happening here.

@tillkamppeter
Copy link
Member Author

@dheeraj135, for the problem with the CUPS Raster header of the imagetoraster filter I am not sure whether they are caused by you (with the "blame" function I see no chenges from you on that code), so it is possible that it was already this way and so printer drivers seem to work correctly with it. If it really was this way before your changes, this is most probably no problem and has always worked.
But what is actually missing on imagetoraster is PWG Raster output support.

@tillkamppeter
Copy link
Member Author

Currently, cups-filters copes with the lack of PWG Raster support by imagetoraster simply by calling imagetopdf and then gstoraster, following its MIME rules.

@dheeraj135
Copy link
Member

pwg-raster is a subset of cups raster. Can we simply remove unsupported options from the cups raster file to convert it to pwg rater file?

@dheeraj135
Copy link
Member

@tillkamppeter Thanks for the fix.

@dheeraj135
Copy link
Member

Major Differences:

  • Header (RaS2 vs RaSt)
  • ColorOrderEnum (bytes 396-399)
  • ColorSpaceEnum (bytes 400-403)
  • LeadingEdge (bytes 308-311)
  • MediaPositionEnum (bytes 324-327) [pwg-raster requires this value to be between 0-49].
  • PrintQuality (bytes 484-487) [PrintQuality is not defined by cups-raster].

All the differences are defined in the pwg raster specification: PWG Raster Format

@tillkamppeter
Copy link
Member Author

I have checked and it seems that imagetoraster all the time centered the images by changing the size of the unprintable margins instead of adding white pixels around the image to the bitmap. So drivers should cope with that. So I am closing this issue as what I have observed in this regard is not actually a bug.
Note that for adding support for PWG Raster you have to add white pixels as PWG Raster does not use unprintable margins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants