The Z variable contains the number of channels (a.k.a. planes) in the image. This includes all color channels and any additional alpha channels available.