Skip to main content
rywalker
Known Participant
June 6, 2019
Answered

Forcing 32 bit PNG export

  • June 6, 2019
  • 3 replies
  • 9736 views

I'm working on a script where I need to export certain assets as 32 bit PNGs (PNG24 + Alpha). When exporting these manually - Quick Export as PNG works perfectly every time and preserves an alpha bit depth - even if the image has no transparency. But Quick Export as PNG doesn't work in scripting.

When I've tried exporting via other means, when the image in question doesn't have transparency the export results in no alpha bit depth. Is there a way to force alpha bit depth via other export means in scripting?

I've tried using various save for web legacy  scripting settings with transparency = true, as well as normal save scripts that set the file type to PNG, but so far the only 2 methods that preserve transparency are Quick Export as PNG and the Generator Image assets - but from what I can tell there is no way to 'toggle' Generator on/off within a script.

Any help would be appreciated!

This topic has been closed for replies.
Correct answer r-bin
Why do you need such files?
Make a white layer mask. Set the top left pixel of mask to level 254. Save PNG in any way.

3 replies

rywalker
rywalkerAuthor
Known Participant
June 10, 2019

The tool for slotting these PNGs sometimes runs into errors if the bit depth is incorrect, so the tool we use to check these files always marks them as failing if they don't have 32 bit bit-depth. Since "Quick Export As..." always saves PNGs as 32 bit, for manual production of these files - it's not a problem. The problem only occurs when you try to automate this process to speed up workflow.

Participating Frequently
May 21, 2022

Quick Export as PNG does not save PNG's as 32 bit for me.

rywalker
rywalkerAuthor
Known Participant
June 10, 2019

Unfortunately part of the reason for this script is so that multiple users on my team can use it - forcing them to install previous versions of Photoshop to run the script is counterintuitive for the end goal of speeding up workflow.

r-binCorrect answer
Legend
June 10, 2019
Why do you need such files?
Make a white layer mask. Set the top left pixel of mask to level 254. Save PNG in any way.

Legend
June 6, 2019

Turn off the layer. Save an empty file as PNG (with not a copy!).

Turn on layer. Save (not save as) the file.

Bingo.

rywalker
rywalkerAuthor
Known Participant
June 10, 2019

Unfortunately resaving the file per your method above does not preserve the alpha bit depth when the layer is turned back on.

Legend
June 10, 2019

Yes, exactly, on CC2018 does not work. On CS6 works.