Conversion
Conversion
PSD files store most binary fields in big-endian byte order.
BigEndianBitConverter reads a big-endian 32-bit integer directly from a
byte array, for cases where you’re working with raw bytes yourself — for
example, from an unrecognized image resource.
Decoding a 32-Bit Big-Endian Value
from aspose_psd_foss.bigendianbitconverter import BigEndianBitConverter
data = bytes([0x00, 0x00, 0x04, 0x10]) # example 4-byte big-endian field
value = BigEndianBitConverter.to_int32(data, 0)
print(f"Decoded value: {value}") # 1040to_int32(byte_array, offset) reads 4 bytes starting at offset and
combines them most-significant-byte-first.
Tips and Best Practices
BigEndianBitConverterprovidesto_int32only in this FOSS build — for 16-bit or 64-bit big-endian values, decode manually with Python’s built-inint.from_bytes(data, byteorder="big").- This utility is for raw bytes you’ve already obtained (see Resources) — normal document loading, editing, and saving never requires it directly.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
IndexError calling to_int32 | The byte array has fewer than 4 bytes available starting at offset | Check len(byte_array) >= offset + 4 before calling |
FAQ
Do I need this for normal document editing?
No — it’s a low-level utility for raw bytes you’ve obtained yourself. Typical loading, editing, and saving (see Core API) never requires it directly.
API Reference Summary
| Class/Method | Description |
|---|---|
BigEndianBitConverter.to_int32(byte_array, offset) | Decodes a big-endian 32-bit integer |