I use PIL, more precisely actual fork Pillow. How can a white block be added to the used image downwards, thereby expanding the image?

fd = urllib.urlopen("http://img13.wikimart.ru/7e/7d/f76af011-5f3d-4f81-94b5-16633e7d7e0b.jpeg") image_file = io.BytesIO(fd.read()) img = Image.open(image_file) 

    1 answer 1

    If the original image does not have an alpha channel, then

     white_block_height = 100 fd = urllib.urlopen("http://img13.wikimart.ru/7e/7d/f76af011-5f3d-4f81-94b5-16633e7d7e0b.jpeg") image_file = io.BytesIO(fd.read()) img = Image.open(image_file) background = Image.new('RGB', (img.size[0], img.size[1] + white_block_height), (255, 255, 255)) background.paste(img, (0, 0)) background.save('test.jpg') 
    • Oh, thank you very much, you really helped! - Timur Musharapov