0

Использую PIL, а точнее актуальный форк Pillow. Как можно прибавить к используемому изображению вниз белый блок, тем самым расширив изображение?

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 ответ 1

1

Если у исходного изображения нет альфа-канала, то

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')
1
  • О, большое спасибо, вы очень помогли! 10 авг 2016 в 15:26

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.