Pro.PNG
— API for parsing PNG images¶
PNG Chunks Enumeration¶
The following code example demonstrates how enumerate the chunks inside of a PNG image:
from Pro.Core import *
from Pro.PNG import *
def parsePNG(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = PNGObject()
if not obj.Load(c) or not obj.Initialize():
return
chunks = obj.GetStoredChunks()
it = chunks.iterator()
while it.hasNext():
offset = it.next()
name = obj.ChunkName(offset)
size = obj.ChunkSize(offset)
print("segment:", name, "- offset:", hex(offset), "- size:", hex(size))
Module API¶
Pro.PNG module API.
Classes:
This class represents a PNG image.
- class PNGObject¶
Bases:
Pro.Core.CFFObject
This class represents a PNG image.
Methods:
ChunkName
(offset)Retrieves the name of a PNG chunk.
ChunkSize
(offset)Retrieves the size of a PNG chunk.
ChunkType
(offset)Retrieves the type of a PNG chunk.
Returns the list of internally stored PNG chunks.
IsChunkNecessary
(type)Checks whether a PNG chunk is essential.
LocateChunks
([wo])Find all PNG chunks in the image.
SetStoredChunks
(chunks)Sets the list of internally stored PNG chunks.
- ChunkName(offset: int) → str¶
Retrieves the name of a PNG chunk.
- Parameters
offset (int) – The offset of the chunk.
- Returns
Returns the name of the chunk if successful; otherwise returns an empty string.
- Return type
str
See also
ChunkSize()
andChunkType()
.
- ChunkSize(offset: int) → int¶
Retrieves the size of a PNG chunk.
- Parameters
offset (int) – The offset of the chunk.
- Returns
Returns the size of the chunk.
- Return type
int
See also
ChunkName()
andChunkType()
.
- ChunkType(offset: int) → int¶
Retrieves the type of a PNG chunk.
- Parameters
offset (int) – The offset of the chunk.
- Returns
Returns the type of the PNG chunk.
- Return type
int
See also
ChunkName()
andChunkSize()
.
- GetStoredChunks() → Pro.Core.NTUIntVector¶
- Returns
Returns the list of internally stored PNG chunks.
- Return type
See also
SetStoredChunks()
andLocateChunks()
.
- IsChunkNecessary(type: int) → bool¶
Checks whether a PNG chunk is essential.
- Parameters
type (int) – The PNG chunk type.
- Returns
Returns
True
if the PNG chunk is essential; otherwise returnsFalse
.- Return type
bool
- LocateChunks(wo: Optional[Pro.Core.NTIWait] = None) → Pro.Core.NTUIntVector¶
Find all PNG chunks in the image.
- Parameters
wo (NTIWait) – Optional wait object.
- Returns
Returns the list of PNG chunks found.
- Return type
See also
SetStoredChunks()
andGetStoredChunks()
.
- SetStoredChunks(chunks: Pro.Core.NTUIntVector) → None¶
Sets the list of internally stored PNG chunks.
- Parameters
chunks (NTUIntVector) – The PNG chunk list.
See also
LocateChunks()
andGetStoredChunks()
.