Skip to content

Add image as layer to PSD #71

Answered by EmilDohne
vonbehr asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Florian,

Thanks for using the PhotoshopAPI and apologies for the late reply. The issue you are encountering is due to the ordering of the channels coming from cv2 which is (height, width, channels). PhotoshopAPI on the other hand requires (channels, height, width) which leads to the error you are encountering. I have updated your code to show how this can be done fairly trivially using numpy.

import psapi
import numpy as np
import cv2

document_color_mode = psapi.enum.ColorMode.rgb
width = 1920
height = 1080
file = psapi.LayeredFile_8bit(document_color_mode, width, height)

# CV2 reads images in packed BGR order by default, we now need to go from packed to planar
# e.g. from BGR BGR BG…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by EmilDohne
Comment options

You must be logged in to vote
0 replies
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