@d-schmidt Great. It's also clear that it `can contain fewer values than there are palette entries` in the `int` case. Wasn't 100% sure.

@wiredfool an `int` does not represent # of bytes, but the index of the color in the palette that should be transparent (value 0). 

I would still truncate it in case the user sets the `bits` which reduces the palette, since `the tRNS chunk must not contain more alpha values than there are palette entries`.

How about:
```
if isinstance(im.encoderinfo["transparency"], int):
    transparency = max(0, min(255, im.encoderinfo["transparency"]))
    alpha = b'\xFF' * transparency + b'\0'
else:
    alpha = im.encoderinfo["transparency"]
# limit to actual palette size
alpha_bytes = 2**bits
chunk(fp, b"tRNS", alpha[:alpha_bytes])
```