When saving images as PNG, the final image colors do not match the original image. Why?

A few users of my Photoshop Plugin have reported this issue, where when exporting the final images as PNG, the colors don’t match the original image.

Here’s the batchPlay code I use for the “save as PNG” operation – any insights as to what may be causing this?

const save_final_image_as_PNG = {
    _obj: "save",
    as: {
        _obj: "PNGFormat",
        method: {
            _enum: "PNGMethod",
            _value: "quick"
        },
        PNGInterlaceType: {
            _enum: "PNGInterlaceType",
            _value: "PNGInterlaceNone"
        },
        PNGFilter: {
            _enum: "PNGFilter",
            _value: "PNGFilterAdaptive"
        },
        compression: PNG_save_quality
    },
    copy: true,
    in: {
        _path: outputFileToken,
        _kind: "local"        
    }
};

result = await app.batchPlay([save_final_image_as_PNG]);

Here is the JPEG save operation for comparison:

    const save_image_as_JPEG = {
        _obj: "save",
        as: {
            _obj: "JPEG",
            extendedQuality: image_save_quality,
            matteColor: {
            _enum: "matteColor",
            _value: "none",
            },
        },
        copy: true,
        in: {
            _path: outputFileToken,
            _kind: "local"        
        }
    };
    result = await app.batchPlay([save_image_as_JPEG]);

Could this also be caused by some setting they have on their specific Photoshop application? Or is there something in the PNG save operation that needs to be overtly specified to make it save the final images to have the colors match the original images?

Thanks!

My first guess would be that their images are in a colour space that has a wider gamut than whatever colour space your PNG is saving out in.

Hmm… you think there’s any kind of UXP Photoshop / batch play parameter I can add to the “save image” operation to neutralize that?

“embedColorProfile: true” is the only thing I can find in the documentation that seems promising. Hard to say for sure if this will even work, however, since I’ve not been able to replicate the issue on my computer – so not a great way for me to troubleshoot it and identify what fixes it.