MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / get_image_properties

Method get_image_properties

png.py:156–179  ·  view source on GitHub ↗

Get all fundamental properties of the image. Store in the instance.

(self)

Source from the content-addressed store, hash-verified

154
155
156 def get_image_properties(self) -> None:
157 """Get all fundamental properties of the image. Store in the instance."""
158 if self.crc == True:
159 Png.check_crc(self.bin, 8)
160
161 self.width = int.from_bytes(self.bin[16:20], byteorder="big")
162 self.height = int.from_bytes(self.bin[20:24], byteorder="big")
163 # Ranging in 1, 2, 4, 8, 16
164 self.bit_depth = self.bin[24]
165 # Ranging in 0, 2, 3, 4, 6
166 # 0 - Grayscale - 1 channel
167 # 2 - RGB - 3 channels
168 # 3 - Palette - 1 channel
169 # 4 - Grayscale Alpha - 2 channels
170 # 6 - RGB Alpha - 4 channels
171 self.color_type = self.bin[25]
172 self.channels = Png.channels_lookup[self.color_type]
173 # default 0
174 self.compression_method = self.bin[26]
175 # default 0
176 self.filter_method = self.bin[27]
177 # 0 - no interlace
178 # 1 - Adam7 algorithm
179 self.interlace_method = self.bin[28]
180
181
182 def get_palette(self) -> None:

Callers 2

__init__Method · 0.95
decodeMethod · 0.95

Calls 1

check_crcMethod · 0.80

Tested by

no test coverage detected