Skip to content

How to create an image with same pixel color? #631

Discussion options

You must be logged in to vote

This more than a few ways to do this. Here are some examples.

from wand.display import display
from wand.drawing import Drawing
from wand.image import Image
import numpy as np

one_pixel_color_rgba = [128, 128, 128, 255]

# Create a new image with a background color.
color_rgba = 'rgba({0}, {1}, {2}, {3})'.format(*one_pixel_color_rgba)
with Image(width=128, height=128, background=color_rgba) as img:
    display(img)

# Read a canvas protocol
canvas = 'canvas:rgba({0}, {1}, {2}, {3})'.format(*one_pixel_color_rgba)
with Image(width=128, height=128, filename=canvas) as img:
    display(img)

# Import raw pixels from Numpy
uniform_color_rgba = np.tile(np.array(one_pixel_color_rgba, dtype='u1')…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by druzhynin-oleksii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants