魔杖伪图像 - Python
Wand 支持许多图像格式规范,即一些使用 soem 算法创建的图像。伪图像非常重要,我们可以使用 wand 中的伪图像对图像进行各种操作。我们可以通过在Image()
函数中设置伪参数来创建伪图像。
Some manipulations we can perform –
1. Create solid color image.
2. Create gradient images.
3. Create images with patterns
4. Creates a fractal image.
一些重要的伪图像:
Pseudo Image | Description |
---|---|
‘canvas:COLOR’, or ‘xc:COLOR’ | Creates image with solid color, here COLOR is color value string |
‘caption:TEXT’ | Add text to image |
‘gradient:START-END’ | Generates a blended gradient between two colors, where both START and END are color value strings. |
‘hald:’ | Creates a Higher And Lower Dimension matrix table. |
‘inline:VALUE’ | where VALUE is a data-url / base64 string value.. |
‘label:TEXT’ | where TEXT is a string message. |
‘pattern:LABEL’ | Generates image with a repeated pattern. |
‘plasma:’ | Generates a plasma fractal image |
‘radial-gradient’ | This is same as gradient but int this there is a circular blend of colors. |
’tile:FILENAME’ | Generates a repeating tile effect from a given images, where FILENAME is the path of a source image.. |
句法 :
with Image(width=image_width, height=image_height,
pseudo='pseudo_type') as img:
# other manipulation code
现在让我们继续研究伪图像的Python代码。
示例 1:创建带有渐变的图像
# Import Image from wand.image module
from wand.image import Image
# Create pseudo image using Image() function
with Image(width = 400, height = 300,
pseudo ='gradient:# 32a852-# 09e846') as img:
# Save image with a validfilename
img.save(filename ='gradient.png')
输出 :
示例 2:创建带有图案的图像
# Import Image from wand.image module
from wand.image import Image
# Create image using Image() and label CROSSHATCH45 for pattern
with Image(width = 100, height = 100, pseudo ='pattern:CROSSHATCH45') as img:
# Save image
img.save(filename ='pattern.png')
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。