[Python] How to create a white image in Python?

Discussão em 'Python' iniciado por Stack, Abril 19, 2025.

  1. Stack

    Stack Membro Participativo

    The following code creates a black picture:

    from scipy.misc import imread,imsave
    from numpy import zeros

    img = zeros([100,100,3])
    for y in range(len(img)):
    for x in range(len(img[0])):
    img[y,x] = [255,255,255]
    imsave("Result.jpg",img)


    I would have assumed it to be white.

    Edit in 2024: The code block is deprecated and won't run anymore.

    Continue reading...

Compartilhe esta Página