---
Product: psd
Platform: python
Page Type: docs
Canonical URL: https://docs.aspose.org/psd/python/developer-guide/conversion
---

# Conversion

Decode a 32-bit big-endian integer from raw PSD resource bytes using BigEndianBitConverter.

## Overview

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

```python
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}")  # 1040
```

`to_int32(byte_array, offset)` reads 4 bytes starting at `offset` and
combines them most-significant-byte-first.

---

### Tips and Best Practices

- `BigEndianBitConverter` provides `to_int32` only in this FOSS build —
  for 16-bit or 64-bit big-endian values, decode manually with Python's
  built-in `int.from_bytes(data, byteorder="big")`.
- This utility is for raw bytes you've already obtained (see
  [Resources](../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](../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 |

## See Also

- [Resources](../resources/)
- [Core API](../core-api/)
- [Aspose.PSD — Enterprise Documentation](https://docs.aspose.com/psd/)