Bug 702893 - tiffsep1 can only handle one halftone
Summary: tiffsep1 can only handle one halftone
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color (show other bugs)
Version: 9.52
Hardware: PC Linux
: P4 enhancement
Assignee: Ray Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-11 09:45 UTC by Martin Schulze
Modified: 2021-10-11 08:03 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Black channel separation with artifacts and same angle for all squares (37.76 KB, image/tiff)
2020-09-11 09:45 UTC, Martin Schulze
Details
x.pam (12.87 KB, application/octet-stream)
2020-09-15 14:19 UTC, Ray Johnston
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schulze 2020-09-11 09:45:06 UTC
Created attachment 19813 [details]
Black channel separation with artifacts and same angle for all squares

I have following example postsrcipt code

```
%!PS-Adobe-3.0

<< /PageSize [99 33] >> setpagedevice

/size 33 def

/rect {
newpath
0 0 moveto
size 0 lineto
size size lineto
0 size lineto
closepath
fill
} def

<< /HalftoneType 1 /Frequency 100 /Angle 60 /SpotFunction { pop } >> sethalftone
0.5 0.5 0.5 0.5 setcmykcolor
rect

size 0 translate
rect

<< /HalftoneType 1 /Frequency 100 /Angle 45 /SpotFunction { pop } >> sethalftone
size 0 translate
rect

showpage
```

Which should render three squares with different halftone screens (default, angle 60, angle 45) next to each other. However, when putting this into `gs -dNOPAUSE -dBATCH -r600 -sDEVICE=tiffsep1 -sOutputFile=test%d.tif test.ps` I get all three with the same halftones and there are artifacts that look like memory corruption in the halftone buffer.

This has been first reported here: https://stackoverflow.com/questions/63827886/is-using-multiple-halftone-screens-on-the-same-page-allowed-in-postscript-3
Comment 1 Martin Schulze 2020-09-11 10:21:48 UTC
Since I can't edit the original post: Originally I had the first sethalftone after the first rect draw command so it would be drawn with the default settings but I tried to simplify the report and mixed things up.

To clarify: We now have 3 squares where the first two should have the same halftone (angle=60)  and the last one another (angle=45) but we still see only one halftone across all 3 of them in the tiffs.
Comment 2 Ray Johnston 2020-09-11 17:21:00 UTC
Sorry for the confusion. The tiffsep1 device actually renders the page in
contone mode, then applies the halftone afterwards.

We might look at changing it (or making another device) that renders the page
to 1-bit planes which would be required for what you want.

This device was developed as an example for a customer that wanted to perform
halftoning that way. They have since implemented their own device.

Note that if the page has transparency, transparency MUST be performed in
contone, so the result will be halftoned all using the halftone in effect at
when the page is complete, so the result will be the same as what you see with
tiffsep1 even with simple monochrome devices like pbmraw or tiffg4.
Comment 3 Martin Schulze 2020-09-15 10:00:40 UTC
Thanks for the quick response. Just to make sure I understand you correctly:
There is currently no way to generate halftoned, channel separated CMYK output with multiple screens in ghostscript?

I understood that tiffsep1 cannot have multiple screens by design but there is also no other device which would allow to achieve that?

Furthermore, it seems that there is some sort of memory corruption when using multiple screens in one file with tiffsep1. Maybe you want to look into that, too.
Comment 4 Ray Johnston 2020-09-15 14:12:53 UTC
Thanks for the comment on the memory corruption.

There is the pamcmyk4 device which generates CMYK. Spot colors are rendered as
CMYK, so overprint is ignored for them, but CMYK can be overprinted, and the
CMYK halftone can be changed.

I've attached the sample output from your file using:

bin/gs -r72 -sDEVICE=pamcmyk4 -o x.pam x.ps

which can be viewed with:

bin/gs -r72 -dSCALE=1 --permit-file-read=x.pam -- lib/viewpbm.ps x.pam

The header of the PAM file looks like this:
P7
WIDTH 99
HEIGHT 33
DEPTH 4
MAXVAL 255
TUPLTYPE CMYK
# Image generated by GPL Ghostscript GIT PRERELEASE
ENDHDR
Comment 5 Ray Johnston 2020-09-15 14:19:39 UTC
Created attachment 19831 [details]
x.pam
Comment 6 Martin Schulze 2020-09-17 11:46:01 UTC
Many thanks for the followup. pamcmyk4 is good enough for our purposes.
Comment 7 Ray Johnston 2020-09-17 15:05:09 UTC
Thank you for letting us know.

The tiffsep1 device will probably stay the way it is because it also allows
for downscaling, which requires 8-bit per plane and halftoning after the
downscale action. The support for the extra downscaler features makes it
worth keeping as is.

We still may do a halftoned device that supports spot color separations.

Note that any such device won't be able to synthesize a 'composite' CMYK
as tiffsep does. I looked at tiffsep1 and it doesn't do that even though the
it could, since it does have the contone data.

Changing this to 'enhancement' since it may lead to doing a CMYK+spot 1-bit
tiff device, or at least adding a CMYK composite to tiffsep1.