pdf-association / pdf-issues

Industry-based resolutions for issues and errata reported against any PDF-related specification
https://pdf-issues.pdfa.org/
63 stars 2 forks source link

Which default color space is applicable to the blend color space of an isolated transparency group Form XObject? #134

Closed DietrichSeggern closed 1 year ago

DietrichSeggern commented 2 years ago

ISO32000-2:2020 Table 145 in "11.6.6 Transparency group XObjects" specifies for the blend color space (CS entry) in a group entry of an isolated transparency group in a Form XObject, that it can be remapped (to an ICCBased color space): "Device colour spaces shall be subject to remapping according to the DefaultGray, DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the current resource dictionary (see 8.6.5.6, "Default colour spaces")."

The question is whether the "current resource dictionary" is the one of the respective Form XObject or of the parent object (the page or a parent Form XObject).

It is clear that for any default colors in the content stream of the respective Form XObject the "current resource dictionary" is the one of this Form XObject (if present, otherwise inherited). But that is not as clear for the blending color space that is defined in the group entry. This blend color space is used for two color conversions (if needed):

  1. "all painting operators shall convert source colours in a colour space (that are not equivalent to the group colour space) to the group colour space before compositing objects" (below Table 145, 4th bullet: "Group colour spaces", first sub bullet).
  2. "The group’s shape [...] shall then be painted into the parent group or page, using the group’s accumulated colour and opacity at each point. If colour conversion needs to take place in order to composite the group into its parent, the rendering intent and black point compensation from the graphics state at the point of invocation of the Do operator shall be used for the conversion." (below Table 145, 5th bullet). In other words for this conversion the parent context is applicable.

The first conversion suggests that the "current resource dictionary" is the one of the group. The second conversion will use the blend color space of the group in order to convert the content of the group into the parent context and then it would be more logical to use the resource dictionary of he parent object.

This sample file has originally been created by some layout software which seems to imply that the DefaultCMYK color space of the page is applied to the blend color space of the Form XObject (DeviceCMYK). (The attached PDF has been massively reduced and modified, but still demonstrates the question.)

Recommendation

The first conversion mentioned above explicitly mentions the blend color space of the group and if that would be the only color conversion the "current resource dictionary" would clearly be the one of the Form XObject itself. The second color conversion does not explicitly refer to the blend color space.

Therefore I think the "current resource dictionary" is indeed the one of the Form XObject itself.

But I think this should somehow be clarified in the standard, even more so since existing applications seem to assume otherwise.

lrosenthol commented 2 years ago

In this specific file, I would think that exactly what CMYK should be used for blend color space of the Form XObject is undefined and that a processor could potentially pick one that they wish.

From a spec point of view, I agree that the place to look ("current resource dictionary") is indeed the one of the Form XObject itself. (and since there isn't one here in this spec, that is why it is undefined)

pkleinheider commented 2 years ago

Is this something that will get fixed in a future version so it is not up to the processor to choose which color space to pick?

As such a PDF can be defined as PDF/X-4 (where the defined Output Intent differs from the defined Default CMYK profile), this would lead to ambiguous results.

petervwyatt commented 2 years ago

@pkleinheider Yes - the current process is for the PDF Association's PDF TWG to agree on a resolution that is suitable to industry, based on the discussions here in GitHub. That can hopefully be done relatively quickly. Then the PDF Association will submit these industry-agreed resolutions to ISO for formal review and approval... but ISO meetings happen less frequently. So you can already see the 90 or so issues that are Closed but with a label of "ISO submitted" are pending an ISO TC 171 SC 2 WG 8 review this coming week. Hope that helps.

So if you have opinions please comment here!

lrosenthol commented 2 years ago

@pkleinheider be aware that the work here is only about improving PDF 2.0 (ISO 32000-2) and has no bearing on PDF 1.x (ISO 32000-1).

Since PDF/X-4 is based on 32000-1, whatever is the outcome of this discussion would not apply. Such processors would continue to behave as they do. However, since PDF/X-6 is based on ISO 32000-2, those processors would be impacted.

DietrichSeggern commented 2 years ago

I agree to Leonard's comment in: https://github.com/pdf-association/pdf-issues/issues/134#issuecomment-1012518569

The only thing we know about the blend color space of the Form XObject in the sample file is that it is DeviceCMYK, there is no device independent color space specified. There is an ICCBased DefaultCMYK on page level, but that does not apply.

DietrichSeggern commented 2 years ago

I propose to change the second paragraph in "Table 145 - Additional entries specific to a transparency group attributes dictionary" in the definition on CS in the last sentence:

The group colour space shall be any device or CIE-based colour space that treats its components as independent additive or subtractive values in the range 0.0 to 1.0, subject to the restrictions described in 11.3.4, "Blending colour space". These restrictions exclude Lab and lightness-chromaticity ICCBased colour spaces, as well as the special colour spaces Pattern, Indexed, Separation, and DeviceN. Device colour spaces shall be subject to remapping according to the DefaultGray, DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the current resource dictionary (see 8.6.5.6, "Default colour spaces"). --> ... Device colour spaces shall be subject to remapping according to the DefaultGray, DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the current resource dictionary of the group XObject (see 8.6.5.6, "Default colour spaces”).

MPBailey commented 2 years ago

11.7.2 para 1 says:

As discussed in 11.6.6, "Transparency group XObjects", an isolated transparency group shall either have an explicitly declared colour space or inherit that of its parent group. If the colour space of the transparency group is a device colour space, and some ancestor of the group has a CIE-based colour space with the same number of colourants, then the colour space of this group shall be the CIE-based space of the nearest such ancestor.

It's not clear how that would interact with applying default colour spaces. Presumably you'd do the default first?

DietrichSeggern commented 2 years ago

11.7.2 para 1 says:

As discussed in 11.6.6, "Transparency group XObjects", an isolated transparency group shall either have an explicitly declared colour space or inherit that of its parent group. If the colour space of the transparency group is a device colour space, and some ancestor of the group has a CIE-based colour space with the same number of colourants, then the colour space of this group shall be the CIE-based space of the nearest such ancestor.

It's not clear how that would interact with applying default colour spaces. Presumably you'd do the default first?

I guess so. If the form XObject (or group XObject) has a group entry with a device color space and a corresponding default color space in its own resources then this default color space is in effect. But if the form XObject does not have its own group entry specifying the color space and inherits it from an ancestor then the current resource dictionary of that ancestor group it taken into account if the default color space mechanism has to be applied.

MPBailey commented 2 years ago

Thanks Dietrich; that would match my expectation.

petervwyatt commented 2 years ago

So any wording improvement suggestions?

MPBailey commented 2 years ago

Insert this parenthetical text into the 2nd sentence of the 1st para of 11.7.2:

If the colour space of the transparency group is a device colour space (after any default colour space remapping), and ...

The biggest risk of that change is that there are probably half a dozen other places where there is equal justification for the same thing.

DietrichSeggern commented 2 years ago

The biggest risk of that change is that there are probably half a dozen other places where there is equal justification for the same thing.

That would be my personal view. I think it is sufficiently clear that a device colour space can only be there if there is no corresponding ICCBased default colour space in the current resource dictionary.

My 2 cents.

petervwyatt commented 2 years ago

PDF TWG agree to change Table 145 as follows (see above 7 Feb DvS):

... Device colour spaces shall be subject to remapping according to the DefaultGray, DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the current resource dictionary of the group XObject (see 8.6.5.6, "Default colour spaces”).

No other changes are to be made because missing an edit could lead to greater confusion.

MPBailey commented 1 year ago

The current WG8 errata draft adds "of the group XObject". I'm not clear that this is sufficient to address page groups as well as group XObjects. It would be better if this were to say "of the transparency group"

DietrichSeggern commented 1 year ago

But chapter 11.6.6. is only about "Transparency group XObjects" not about pages as a group.

It is clear and was always clear that it is the color space of the transparency group, so "of the transparency group" would not clarify anything. But it is not as clear whether it will use the default color space of the ancestor XObject (or page) or of the XObject in which the group is defined. We want to clarify that the latter is the case.

petervwyatt commented 1 year ago

In tidying up errata in readiness for the October PDF Week, noted that this issue was re-opened.

The earlier edit to Table 145 has already been approved by WG8 but did not make it into Amd1: https://pdf-issues.pdfa.org/32000-2-2020/clause11.html#Table145

@MPBailey @DietrichSeggern - do either of you feel any further changes are needed? PS. I'm temporarily labelling it as "proposed solution" so it also stays on my radar for the next PDF TWG

DietrichSeggern commented 1 year ago

I am fine with the proposed text and do not think that we should do anything beyond it (in this context).

MPBailey commented 1 year ago

I'm not 100% convinced that it's clear that the change discussed above applies to transparency groups and not to page groups. After all, the first sentence of 11.4.7 (Page Groups) says that a page group shall be treated as if it were a transparency group. In addition a page group uses the same group attributes dictionary as a transparency group and 'Group' in Table 31 (Page objects) cross-references to 11.6.6 (Transparency group XObjects), which includes Table 145.

So, if a page group is treated as if it were a transparency group (11.4.7) would it not be better to have CS in Table 145 say "current resource dictionary of the transparency group" rather than "current resource dictionary of the group XObject"?

petervwyatt commented 1 year ago

I'd be happy with that improvement to the current wording of the change. Let's discuss this in the next PDF TWG meeting to get a consensus (again).

DietrichSeggern commented 1 year ago

I think we are now at where we started. The issue was that it is not clear whether the "current resource dictionary" for a transparency group (that is not the page) is the one that was current when the XObject was invoked or the one that is current thereafter (i.e. used inside of the XObject). I think "of the transparency group" does not clarify that.

I then suggest to add a new sentence to the end of the existing text, see:

... Device colour spaces shall be subject to remapping according to the DefaultGray, DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the current resource dictionary (see 8.6.5.6, "Default colour spaces"). For a group XObject that shall be the resource dictionary that is current inside of the XObject.

petervwyatt commented 1 year ago

On re-reviewing PDF TWG would like to change wording to "... of the transparency group XObject".