Mask and PNG #45622

Closed
opened 2015-07-30 18:00:27 +02:00 by José Ricarte · 15 comments

When render in the compositor the node "Matte_Keying" and output to PNG RGBA, only Alfa pixels are write "1", but the previous values of RGB color of the pixels with alpha 0 remains , that means that the weight of the image is still large, the pixel information with alpha=0 should also be unified to black for PNG compression to take effect
see images:

The same image

0001.png 458 k
0652.png 8 M!!!!

nodes:

nodes.jpg

When render in the compositor the node "Matte_Keying" and output to PNG RGBA, only Alfa pixels are write "1", but the previous values of RGB color of the pixels with alpha 0 remains , that means that the weight of the image is still large, the pixel information with alpha=0 should also be unified to black for PNG compression to take effect see images: The same image ![0001.png](https://archive.blender.org/developer/F216153/0001.png) 458 k ![0652.png](https://archive.blender.org/developer/F216156/0652.png) 8 M!!!! nodes: ![nodes.jpg](https://archive.blender.org/developer/F216159/nodes.jpg)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @ciriaco

Added subscriber: @ciriaco
Author

This comment was removed by @ciriaco

*This comment was removed by @ciriaco*
Author

If you open the two images in the composer without applying transparency "use alpha" will see that the image of 8M still has the RGB information in the transparent pixels

Blender output render image (PNG, RGBA, 5% compression ratio): 8 M !!!!

2.jpg

Open the image 8 M in gimp, and save again but this time with the option
"not save values on transparent pixels" and 10% compression ratio, the image now weighs 458 K

gimp.jpg

Gimp saved 458 k

1.jpg

If you open the two images in the composer without applying transparency "use alpha" will see that the image of 8M still has the RGB information in the transparent pixels Blender output render image (PNG, RGBA, 5% compression ratio): **8 M !!!!** ![2.jpg](https://archive.blender.org/developer/F216173/2.jpg) Open the image 8 M in gimp, and save again but this time with the option "not save values on transparent pixels" and 10% compression ratio, the image now weighs 458 K ![gimp.jpg](https://archive.blender.org/developer/F216197/gimp.jpg) Gimp saved **458 k** ![1.jpg](https://archive.blender.org/developer/F216171/1.jpg)

Added subscriber: @Sergey

Added subscriber: @Sergey

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sergey Sharybin self-assigned this 2015-07-31 14:04:33 +02:00

That is a wrong assumption that channels with zero alpha should be black. PNG is a straight alpha as per standard and blender follows that. You can still force transparent pixels to be black in compositor tho, so wouldn't consider it a bug.
Thanks for the report anyway.

That is a wrong assumption that channels with zero alpha should be black. PNG is a straight alpha as per standard and blender follows that. You can still force transparent pixels to be black in compositor tho, so wouldn't consider it a bug. Thanks for the report anyway.
Author

Hello, I think it's a bug Because if I try to make transparent pixels RGB value to black, also recording RGB information and no compress, the image is still weighing 8 M

blender.jpg

I think that there should be an option in the PNG output to not record RGB values in the transparent pixels as in gimp. This is important to save memory in long productions

http://thesecondmanproductions.blogspot.com.es/
https://www.youtube.com/watch?v=FAC4m11p4KI

Thanks for your work

Hello, I think it's a bug Because if I try to make transparent pixels RGB value to black, also recording RGB information and no compress, the image is still weighing 8 M ![blender.jpg](https://archive.blender.org/developer/F216399/blender.jpg) I think that there should be an option in the PNG output to not record RGB values in the transparent pixels as in gimp. This is important to save memory in long productions http://thesecondmanproductions.blogspot.com.es/ https://www.youtube.com/watch?v=FAC4m11p4KI Thanks for your work

There is no such thing as "not record RGB values in the transparent pixels", all the pixels do exist in the file.

Also i can't confirm here that making RGB channels black for alpha=0 doesn't help. It sames like 4x of the image size. It's hard to compare it with the result of gimp you're having because your 8meg file and 400kb files are made from different frames.

Here's an example of how you can do the trick for RGB colors: png.blend

There is no such thing as "not record RGB values in the transparent pixels", all the pixels do exist in the file. Also i can't confirm here that making RGB channels black for alpha=0 doesn't help. It sames like 4x of the image size. It's hard to compare it with the result of gimp you're having because your 8meg file and 400kb files are made from different frames. Here's an example of how you can do the trick for RGB colors: [png.blend](https://archive.blender.org/developer/F216403/png.blend)
Author

Hi,

"There is no such thing as "not record RGB values in the transparent pixels", all the pixels do exist in the file."

in gimp yes:

gimp.jpg

Hi, "There is no such thing as "not record RGB values in the transparent pixels", all the pixels do exist in the file." in gimp yes: ![gimp.jpg](https://archive.blender.org/developer/F216413/gimp.jpg)
Author

Thanks for the example !!

A bit complicated for artist... not very intuitive.

I think is better the solution of gimp... press a buton "not save the RGB values in trasparent pixels"

Thanks for your work

Thanks for the example !! A bit complicated for artist... not very intuitive. I think is better the solution of gimp... press a buton "not save the RGB values in trasparent pixels" Thanks for your work
Author

"Also i can't confirm here that making RGB channels black for alpha=0 doesn't help. "

Hi, I think that yes it helps, because the PNG compressor groups all the same RGB value pixels in an indexed list. The important thing is that transparent pixels have the same RGB value (black or color you want) then compression acts.

"Also i can't confirm here that making RGB channels black for alpha=0 doesn't help. " Hi, I think that yes it helps, because the PNG compressor groups all the same RGB value pixels in an indexed list. The important thing is that transparent pixels have the same RGB value (black or color you want) then compression acts.
Author

I researched a bit and I made a comparative test:

Base frame 8 M:

0258.png

Saved : PNG RGBA, 15% compression, pixels alfa=0 with RGB initial values = 2,8 MB

B1.png

Saved : PNG RGBA, 15% compression, pixels alfa=0, with RGB= black= 1,6 MB

B2.png

With transparent pixels normalized to black: aprox -40% storage use

I researched a bit and I made a comparative test: Base frame 8 M: ![0258.png](https://archive.blender.org/developer/F216842/0258.png) Saved : PNG RGBA, 15% compression, pixels alfa=0 with RGB initial values = 2,8 MB ![B1.png](https://archive.blender.org/developer/F216830/B1.png) Saved : PNG RGBA, 15% compression, pixels alfa=0, with RGB= black= 1,6 MB ![B2.png](https://archive.blender.org/developer/F216839/B2.png) With transparent pixels normalized to black: aprox -40% storage use

PNG's compression exploits color similarity across the Y axis of the image, so surely increasing this similarity (by setting colors to black) improves compression and reduces overall file size.

It would be nice to have a tool to make operation of setting transparent pixels to black, but it's out of the scope of the bug tracker.

PNG's compression exploits color similarity across the Y axis of the image, so surely increasing this similarity (by setting colors to black) improves compression and reduces overall file size. It would be nice to have a tool to make operation of setting transparent pixels to black, but it's out of the scope of the bug tracker.
Author

Thanks for your reply, yes, it would be interesting to develop this tool Because it would help the films production in blender. = :-)

Sorry for the noise in the channel

Thanks for your work

Thanks for your reply, yes, it would be interesting to develop this tool Because it would help the films production in blender. = :-) Sorry for the noise in the channel Thanks for your work
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#45622
No description provided.