Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Save RGBA image in psd format #25

Open
magnanta opened this issue Aug 13, 2019 · 7 comments
Open

How to Save RGBA image in psd format #25

magnanta opened this issue Aug 13, 2019 · 7 comments

Comments

@magnanta
Copy link

what is the color mode in nested_layers.nested_layers_to_psd(layers, color_mode=3,) if we want to save RGBA in psd .if i used color mode as 3 it writting only RGB in psd .

code_psd.log
check at line number 37 .

@Twice22
Copy link

Twice22 commented Jan 10, 2020

Have you try:

channels[0] = your_numpy_img[:, :, 0]  # Red
channels[1] = your_numpy_img[:, :, 1]  # Blue
channels[2] = your_numpy_img[:, :, 2]  # Green
channels[-1] = your_numpy_img[:, :, 3]  # Alpha

@magdev2022
Copy link

I tried with above commands. But alpha channel is converted into white background.

@magdev2022
Copy link

I have done. Very thanks.

@ashikrafi
Copy link

hi @yiming1995,

could you please share the full code? I have tried to add a transparent image to PSD layer. But after adding the layer to the PSD file, the background gets black.

@Laroustine
Copy link

@magdev2022,
I do not understand how you managed to remove the black on transparent pictures.

@magdev2022
Copy link

Can you share code and problem here?

@cman122887
Copy link

only way i got this to work was by passing enums.ColorMode.rgb for color mode and None in channels during creation of the Image and then using set_channel afterwards.
v1.2.1 of pytoshop

image = nested_layers.Image(name='test',visible=True,opacity=255,group_id=0,blend_mode=enums.blendMode.normal,top=0,left=0, channels=None, metadata=None,layer_color=0,color_mode=enums.ColorMode.rgb)
image.set_channel(enums.ColorChannel.red,your_numpy_img[:,:,0])
image.set_channel(enums.ColorChannel.green,your_numpy_img[:,:,1])
image.set_channel(enums.ColorChannel.blue,your_numpy_img[:,:,2])
image.set_channel(enums.ColorChannel.transparency,your_numpy_img[:,:,3])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants