Size and transparency differences when saving PNG by different methods

I’m exporting PSD layers to PNGs for a game’s texture atlases.

When I’m doing Copy -> New File (RGB 8-bit) -> Save As PNG, the resulting PNG is quite heavy and Finder shows white background instead of transparent.

But when I’m using Export Layers to Files (24-bit PNG), the resulting PNG is 70-95% smaller.

images

I don’t need any compression by Photoshop – my texture creating software can do it well by itself. But I’d like to export layers by script instead of saving them manually.

  1. What makes Saved As PNG that heavy? Do exported images lose any color information or are reduced in quality?
  2. Why is transparency different?

Answer

Copying 54kb PNG file to Windows XP VM decreased file size to 5kb. OS X Photoshop version adds “com.apple.resourcefork” attribute to file during regular saving. You can see it by ls -l@ filename.png. The attribute is not included in file, but the file system shows total size. The white background from the screenshot seems to appear because of this attribute. PNGs with normal file size are displayed with transparent backgrounds.

Without the attribute the size of PNG is about 5kb. It was reduced to 1.6kb by removing iTXt(870b), pHYs (9b), iCCP (2.64kb) and cHRM (32b) chunks with pngcrush.

When “Saving for Web & Devices” Photoshop still adds ancillary tEXt/zTXt chunks to the file: 0 Software: Adobe ImageReady and about 2000 XML symbols like: 1 XML:com.adobe.xmp (: ):
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/"...

UPD: I missed “Metadata” option in “Save for Web & Devices” dialog window. “None” adds only 0 Software: Adobe ImageReady to the file. File size reduced from 3.6kb to 2.5kb.

So, the end file sizes are:

  • Photoshop “Save as”: 5.4kb (and OS X uses 90% more space to store it)
  • Photoshop “Save for Web”, Metadata=None: 2.5kb
  • pngcrush (-rem alla -rem text): 1.6kb

Attribution
Source : Link , Question Author : Ivan Mir , Answer Author : Ivan Mir

Leave a Comment