Cropping a volume (stack of 2D slices) in python

I have a set of 3D data (Volume of MRI) .nii images with the shape 98-by-240-by-342 (98:slices, 240:W and 342: H), for example. The sizes of volumes are varying from each other. I want to do center-cropping of the all volumes in a way that if width or height is less than 256, that dimension is padded with zeros. I know this can be done by applying on each slice separately, however, I am asking whether if there is a medical image analysis tool that can crop width and heights in a volume?