mattiasw/ExifReader

How to read cliping path and check if the image is transparent

Closed this issue · 8 comments

Is there any way to read cliping path and if the image is transparent?

Hi! For clipping path, if it's in the image metadata it should be possible. Do you have an example image? For transparency it may work depending on image format. PNGs e.g. have a Color Type value that tells if it has an alpha channel or not.

Hi the image format is TIFF and I cannot attach here. If you want then I can send you in email.

I got the files and I've started looking into it. One thing that already works is checking for transparency in PNG files. Look for Color Type. If the image is transparent it will have RGB with Alpha in the description field.

Hi Mattiasw, Thank you for your info.

That was a bit tricky but I can finally get the clipping path now. The question now is how one would like the output to look. I'm not used to using clipping paths so I'm not sure what one wants. Right now the output comes as a JSON looking like below. Is it clear what those mean? Do you have any other ideas on how to present the results? It would be good to get rid of description in there since it takes up a lot of space but I'm not sure if people can understand what the types are if they are just numbers (they come from the Photoshop specification).

[
    {
        "type": 6,
        "description": "Path fill rule",
        "path": []
    },
    {
        "type": 8,
        "description": "Initial fill rule",
        "path": [
            0
        ]
    },
    {
        "type": 0,
        "description": "Closed subpath length",
        "path": [
            1468
        ]
    },
    {
        "type": 2,
        "description": "Closed subpath Bezier knot, unlinked",
        "path": [
            [
                0.10080385208129883,
                0.4790918231010437
            ],
            [
                0.09999996423721313,
                0.47999995946884155
            ],
            [
                0.09999996423721313,
                0.48883241415023804
            ]
        ]
    },
    {
        "type": 2,
        "description": "Closed subpath Bezier knot, unlinked",
        "path": [
            [
                0.09999996423721313,
                0.49766749143600464
            ],
            [
                0.09999996423721313,
                0.5064999461174011
            ],
            [
                0.09999948740005493,
                0.5108041167259216
            ]
        ]
    }
]

Alternative output:

{
    "types": {
        "0": "Closed subpath length",
        "2": "Closed subpath Bezier knot, unlinked",
        "6": "Path fill rule",
        "8": "Initial fill rule"
    },
    "paths": [
        {
            "type": 6,
            "path": []
        },
        {
            "type": 8,
            "path": [
                0
            ]
        },
        {
            "type": 0,
            "path": [
                1468
            ]
        },
        {
            "type": 2,
            "path": [
                [
                    0.10080385208129883,
                    0.4790918231010437
                ],
                [
                    0.09999996423721313,
                    0.47999995946884155
                ],
                [
                    0.09999996423721313,
                    0.48883241415023804
                ]
            ]
        },
        {
            "type": 2,
            "path": [
                [
                    0.09999996423721313,
                    0.49766749143600464
                ],
                [
                    0.09999996423721313,
                    0.5064999461174011
                ],
                [
                    0.09999948740005493,
                    0.5108041167259216
                ]
            ]
        }
    ]
}

Second structure seems good

Released as version 4.18.0.