skip to Main Content
from wand.image import Image

with Image(filename="base.png") as img:
    img.read(filename="background.png")
    img.read(filename="image.png")
    img.read(filename="sub_box.png")
    img.read(filename="cta_box.png")
    img.read(filename="sub_text.png")
    img.read(filename="cta_text.png")
    img.save(filename="final.psd")

I wrote this code to stack png images into a psd file

The code does work, the file has all the layers, but the color is all grayscale
(png images aren’t grayscale)

https://docs.wand-py.org/en/0.6.13/wand/image.html

Any ideas for solving this problem?

I tried to change the image.format to psd, checked the image.colorspace but couldn’t solve the problem

2

Answers


  1. Chosen as BEST ANSWER

    The problem was quite simple: When I changed the first line to

    with Image(filename="background.png") as img:

    It solved the issue

    I guess you should first read the file you opened for some reason


  2. from wand.image import Image
    
    with Image() as img:
        with Image(filename="base.png") as base:
            img.composite(base, 0, 0)
        layer_img_pth= ["background.png", "image.png", "sub_box.png", "cta_box.png", "sub_text.png", "cta_text.png"]
        for layer in layer_img_pth:
            with Image(filename=layer) as layer_img:
                img.composite(layer_img, 0, 0)
        img.format = 'psd'
        img.save(filename="final.psd")
    

    This will help you stack images one over other. Also if have examples of files please attach it to question itself.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search