# Combine images vertically

Recently I needed to combine a bunch of images for a book. Since I didn’t want to use a software I thought it would be easier to combine them using Python with the following script (thanks to Python Programming):

```
import numpy as np
from PIL import Image
import glob
list_im = glob.glob('*.png')
imgs = [ Image.open(i) for i in list_im ]
# choose the minimum size and resize the other ones
min_shape = sorted( [(np.sum(i.size), i.size ) for i in imgs])[0][1]
imgs_comb = np.vstack( (np.asarray( i.resize(min_shape) ) for i in imgs ) )
imgs_comb = Image.fromarray( imgs_comb)
imgs_comb.save( 'imagename.png')
```

Written on December 17, 2019