Photoshop "Display Info" Decoding

Started by blue-j, November 23, 2024, 03:27:20 PM

Previous topic - Next topic

blue-j

i can hack the source, but a first step would be to change the name collision in Photoshop.pm:

    0x03ef => { Unknown => 1, Name => 'DisplayInfo' },
    0x0435 => { Unknown => 1, Name => 'DisplayInfo' }

0x03ef is obsolete and effectively replaced by 0x0435.  i recommend leaving 0x03ef as is, but changing 0x0435 to "ChannelOptions" - as that is exactly what it is (see attached).

this is important metadata, as it informs programmatic interactions with alpha channels in PSD files.

i'm almost done decoding it, will share soon.  - J

Screenshot 2024-11-22 at 10.55.38 PM.png

Phil Harvey

OK, I'll change the name to ChannelOptions.  I'll add decoding if it makes sense after you figure it out.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

#2
ok, the 0x0435 block starts with a fixed header/ID of:

    00 00 00 01

then each alpha channel gets 13 bytes:

    00 01 ff ff ff ff ff ff 00 00 00 32 01

that last byte (13th) always indicates the user's selection of what the color indicates (see above screenshot):

    01  Masked Areas
    00  Selected Areas
    02  Spot Color

the 12th byte indicates the percentage opacity of the mask color (see screenshot again):

    32 -> 50%, hex to decimal
    4B -> 75%
    5A -> 90%, etc

the color value decoding is evading me still, dagnabbit.  the hex is always white, with the exception of pure green.  can't crack it yet.



more samples (i've attached a few) and information:

Test Case  Channel Type    Color  Opacity (%) Hex Data
1  Masked Areas    Red (#FF0000)  50%    00 00 00 01 00 01 FF FF FF FF FF FF 00 00 00 32 01
2  Selected Areas  Red (#FF0000)  50%    00 00 00 01 00 01 FF FF FF FF FF FF 00 00 00 32 00
3  Spot Color  Red (#FF0000)  50%    00 00 00 01 00 01 FF FF FF FF FF FF 00 00 00 32 02
4  Masked Areas    Green (#00FF00) 75%    00 00 00 01 00 00 00 00 FF FF 00 00 00 00 00 4B 01
5  Masked Areas    #C1951E (RGB: 193, 149, 30) 90%    00 00 00 01 00 01 1F 1F D8 D8 C1 C1 00 00 00 5A 01
6  Masked Areas    #0018FF (RGB: 0, 24, 255)  10%    00 00 00 01 00 01 A6 A6 FF FF FF FF 00 00 00 0A 01
7  Masked Areas, then Selected Areas (2 channels in one file)  Red (#FF0000)  50%    00 00 00 01 00 01 ff ff ff ff ff ff 00 00 00 32 01 00 01 ff ff ff ff ff ff 00 00 00 32 00
    00 00 00 01  header/fixed ID
    00 01 ff ff ff ff ff ff 00 00 00 32 01  Alpha 1
    00 01 ff ff ff ff ff ff 00 00 00 32 00  Alpha 2

8  Masked, Selected, Spot, Masked (4 channels in 1 file)  Red (#FF0000)  50%    00 00 00 01 00 01 ff ff ff ff ff ff 00 00 00 32 01 00 01 ff ff ff ff ff ff 00 00 00 32 00 00 01 ff ff ff ff ff ff 00 00 00 32 02 00 01 ff ff ff ff ff ff 00 00 00 32 01
    00 00 00 01  header/fixed ID
    00 01 ff ff ff ff ff ff 00 00 00 32 01  Alpha 1
    00 01 ff ff ff ff ff ff 00 00 00 32 00  Alpha 2
    00 01 ff ff ff ff ff ff 00 00 00 32 02  Alpha 3
    00 01 ff ff ff ff ff ff 00 00 00 32 01  Alpha 4





adobe's documentation:

Edit channel options
To change options for an existing channel, double-click the channel thumbnail in the Channels panel or select Channel Options from the Channels panel menu.

Options available in the New Channel and Channel Options dialog boxes:

Masked Areas
Sets masked areas to black (opaque) and selected areas to white (transparent). Painting with black increases the masked area; painting with white increases the selected area. When this option is selected, the Quick Mask button in the toolbox becomes a white circle on a gray background .

Selected Areas
Sets masked areas to white (transparent) and selected areas to black (opaque). Painting with white increases the masked area; painting with black increases the selected area. When this option is selected, the Quick Mask button in the toolbox becomes a gray circle on a white background .

Spot Color
Converts an alpha channel to a spot color channel. Only available for existing channels.

Color
Sets the color and opacity of the mask. Click the color field to change the color. The color and opacity settings affect only the appearance of the mask and have no effect on how underlying areas are protected. Changing these settings may make the mask more easily visible against the colors in the image.

blue-j

just a quick addition for any decoders out there.  the adobe file format spec speaks of a color structure:

https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577411_31265

perhaps that will be helpful in figuring out what they are doing here.

- J

blue-j

#4
holy shit, pardon my french, but after a ridiculous amount of hours i cracked the code entirely. ok, let's look at some examples:

 
00 00 00 01 00    00    ff ff ff ff 00 00    00 00    00    32 01

00 00 00 01 00    header, doesn't change

00 = RGB  color space ID

this is the color space of the color values to be provided, NOT the image's color space:
00 RGB
01 HSB
02 CMYK
07 Lab
08 Grayscale


ff ff ff ff 00 00 -> FFFF FFFF 0000 (16 bit) -> 65525 65535 0 (decimal) -> 255 255 0 (8-bit)

00 00 - unused "Four short unsigned integers with the actual color data. If the color does not require four values, the extra values are undefined and should be written as zeros"

00 - padding always there

32 -> decimal 50 -> 50% opacity

01 -> Masked Areas

Color Indicates:
    01  Masked Areas
    00  Selected Areas
    02  Spot Color

 


00 00 00 01 00      01     4a 4a 6b 6b b9 b9     00 00     00     32 01

00 00 00 01 00    header, doesn't change

01 = HSB color space ID

4A4A 6B6B B9B9 -> 19018 27499 47545 (16 bit HSB decimal) -> 105°, 42%, 73% scaled to 0-360°, 0-100%, 0-100%   (int, like adobe does)

00 00 - unused "Four short unsigned integers with the actual color data. If the color does not require four values, the extra values are undefined and should be written as zeros"

00 - padding always there

32 -> decimal 50 -> 50% opacity

01 -> Masked Areas




00 00 00 01 00     01     12 12 82 82 ff ff    00 00     00     4b 00

01   another HSB color space ID

1212 8282 FFFF -> 19018 27499 47656 -> 105° 42% 73%

00 00 - unused "Four short unsigned integers with the actual color data. If the color does not require four values, the extra values are undefined and should be written as zeros"

00 - padding always there

4b -> 75% opacity decimal

00 - Selected Areas



00 00 00 01 00      01      66 66 82 82 ff ff      00 00      00     4b 02

another HSB

6666 8282 FFFF -> 26214 33410 65535 -> 144° 51% 100%

00 00 unused

00 padding

4b -> 75% solidity decimal   in the case of spot colors, this is called "solidity" note

02 -> Spot Color



files can have multiple channel options in play when there is more than one channel

00 00 00 01 00 01 91 91 82 82 ff ff 00 00 00 32 01 00 01 49 49 82 82 ff ff 00 00 00 32 00 ->

00 00 00 01 00
01
91 91 82 82 ff ff
00 00
00
32
01

00   <-note padding

01
49 49 82 82 ff ff
00 00
00
32
00



an example with three channels:
00 00 00 01 00 01 91 91 82 82 ff ff 00 00 00 32 01 00 01 49 49 82 82 ff ff 00 00 00 32 00 00 01 49 49 e7 e7 56 56 00 00 00 32 02

00 00 00 01 00
01
91 91 82 82 ff ff
00 00
00
32
01

00

01
49 49 82 82 FF FF
00 00
00
32
00

00

01
49 49 E7 E7 56 56
00 00
00
32
02


the whole shebang is "ChannelOptions" albeit the dialog also shows the alpha name, which exiftool parses elsewhere and is not present in this location.

ColorIndicates is the name for the choices: Masked Areas, Selected Areas, and Spot Color

and then Color and Color Opacity.  if spot color, that becomes Ink Color and Ink Solidity instead of opacity.

Screenshot 2024-12-06 at 12.59.17 AM.png

let me know if you have any questions about this, or see a mistake.  thank you!

- J






blue-j

this sample pack may be easier to work with.  - J

Phil Harvey

Thanks.  I've been busy recently working on other features but I'll look into this when I get a chance.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

This seems potentially useful.  Here is what I have implemented so far:

> exiftool tmp '-*channel*' -G1
======== tmp/selected_peach_75%.psd
[Photoshop]     Num Channels                    : 4
[Photoshop]     Alpha Channels Names            : Alpha 1
[Channel0]      Channel Color Space             : HSB
[Channel0]      Channel Color Data              : 4626 33410 65535 0
[Channel0]      Channel Opacity                 : 75%
[Channel0]      Channel Color Indicates         : Selected Areas
======== tmp/masked_chartreuse_50%.psd
[Photoshop]     Num Channels                    : 4
[Photoshop]     Alpha Channels Names            : Alpha 1
[Channel0]      Channel Color Space             : HSB
[Channel0]      Channel Color Data              : 21074 50372 58082 0
[Channel0]      Channel Opacity                 : 50%
[Channel0]      Channel Color Indicates         : Masked Areas
======== tmp/masked_selected_spot.psd
[Photoshop]     Num Channels                    : 6
[Photoshop]     Alpha Channels Names            : Alpha 1, Alpha 1 copy, Alpha 1 copy 2
[Channel0]      Channel Color Space             : HSB
[Channel0]      Channel Color Data              : 37265 33410 65535 0
[Channel0]      Channel Opacity                 : 50%
[Channel0]      Channel Color Indicates         : Masked Areas
[Channel1]      Channel Color Space             : HSB
[Channel1]      Channel Color Data              : 18761 33410 65535 0
[Channel1]      Channel Opacity                 : 50%
[Channel1]      Channel Color Indicates         : Selected Areas
[Channel2]      Channel Color Space             : HSB
[Channel2]      Channel Color Data              : 18761 59367 22102 0
[Channel2]      Channel Opacity                 : 50%
[Channel2]      Channel Color Indicates         : Spot Color
======== tmp/masked_selected.psd
[Photoshop]     Num Channels                    : 5
[Photoshop]     Alpha Channels Names            : Alpha 1, Alpha 1 copy
[Channel0]      Channel Color Space             : HSB
[Channel0]      Channel Color Data              : 37265 33410 65535 0
[Channel0]      Channel Opacity                 : 50%
[Channel0]      Channel Color Indicates         : Masked Areas
[Channel1]      Channel Color Space             : HSB
[Channel1]      Channel Color Data              : 18761 33410 65535 0
[Channel1]      Channel Opacity                 : 50%
[Channel1]      Channel Color Indicates         : Selected Areas
    1 directories scanned
    4 image files read

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

wow, how awesome!  i am meditating on the nomenclature - we don't want to be ambiguous that this is about the DISPLAY of the channel, not about its contents.  it's a bit confusing!

may i suggest:

Num Channels
Alpha Channel Names
Channel Appearance Color Space
Channel Appearance Color
Channel Appearance Color Opacity
Channel Appearance Color Indicates

a mouthful for sure, but important distinction.  from adobe:

QuoteThe color and opacity settings affect only the appearance of the mask and have no effect on how underlying areas are protected. Changing these settings may make the mask more easily visible against the colors in the image

would you like to decode the color values?  i can help if needed.  obviously they are stored as 16 bit but the user only ever sees integer 8-bit values (no matter what bit depth the image is in) or transformed into the ranges typical of the color space (0-360°, 0-100%, 0-100% for HSB, for example):

Screenshot 2024-12-13 at 7.12.06 PM.png

i believe the color space ID is set by wherever the radio button is selected when saved.

The biggest drag may be scaling Lab values.  i dont think i gave you a sample of that, or CMYK?  lemme know. thanks for doing this!  i learned a lot in the process and have become more useful to the effort.

- J





Phil Harvey

I'll add a note in the tag name documentation that these tags apply only the the appearance of a channel.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

Thanks so much for including this!  I do see a minor tweak to make, i believe?  presently, this:

exiftool -Photoshop:ChannelColorIndicates masked_selected_spot.psd
emits one value only (the last value).

Channel Color Indicates        : Spot Color
I expected a list ordered in parallel to the alpha channel names list (and IDs).  of course i can just add the -a switch:

Channel Color Indicates        : Masked Areas
Channel Color Indicates        : Selected Areas
Channel Color Indicates        : Spot Color

but I wanted to check with you on what you intended.  Sample attached.

- J

Phil Harvey

Sorry for the delay in responding.  Yes, this is as desired:

> exiftool masked_selected_spot.psd -a "-channel*" -G1
[Channel0]      Channel Color Space             : HSB
[Channel0]      Channel Color Data              : 37265 33410 65535 0
[Channel0]      Channel Opacity                 : 50%
[Channel0]      Channel Color Indicates         : Masked Areas
[Channel1]      Channel Color Space             : HSB
[Channel1]      Channel Color Data              : 18761 33410 65535 0
[Channel1]      Channel Opacity                 : 50%
[Channel1]      Channel Color Indicates         : Selected Areas
[Channel2]      Channel Color Space             : HSB
[Channel2]      Channel Color Data              : 18761 59367 22102 0
[Channel2]      Channel Opacity                 : 50%
[Channel2]      Channel Color Indicates         : Spot Color

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).