You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to merge two PNG file into a PSD file, but the result showed that it failed to show the opacity attributes. I don't know if I failed to find a correct module to run this operation, or that I had inputed wrong attributes. If it's the case that I found a wrong module, can someone please show me the original source code that directly addresses alpha channels?
What I Did
import pytoshop
from pytoshop.user import nested_layers
from pytoshop import enums
import numpy as np
from scipy import misc #read png
from PIL import Image
import numpy as np
img2 = misc.imread('2.png')
#print(img2)
print('img2:',img2.shape)
img2_t = np.transpose(img2, (2, 0, 1))
#print(img2_t)
print('img2_t:',img2_t.shape)
#img2_t = np.transpose(img2_t, (1, 2, 0))
#misc.imsave('2_t.png',img2_t)
img4 = misc.imread('4.png')
#print(img4)
print('img4:',img4.shape)
img4_t = np.transpose(img4, (2, 0, 1))
#print(img4_t)
print('img4_t:',img4_t.shape)
#img4_t = np.transpose(img4_t, (1, 2, 0))
#misc.imsave('4_t.png',img4_t)
new_layer = pytoshop.user.nested_layers.Image(
name='2.png',
visible=True,
opacity=255,
group_id=0,
blend_mode= b'norm',
top=250,
left=250,
#bottom=1000,
#right=1000,
# channels=(3,1000,1000),
channels=img2_t,
metadata=None,
layer_color=7,
color_mode=3
)
new_layer2 = pytoshop.user.nested_layers.Image(
name='4.png',
visible=True,
opacity=255,
group_id=0,
blend_mode= b'norm',
top=0,
left=0,
#bottom=500,
#right=500,
# channels=(3,1000,1000),
channels=img4_t,
metadata=None,
layer_color=7,
color_mode=3
)
lays = [new_layer,new_layer2]
new_psd = pytoshop.user.nested_layers.nested_layers_to_psd(lays, color_mode=3, version=1, compression=1, depth=8, vector_mask=False)
print('new_layer:',new_layer)
#print(dir(new_layer))
print('_________________________________')
#print(new_layer.name)
#print('---new_psd:---',type(new_psd))
# # new_psd = pytoshop.user.nested_layers.nested_layers_to_psd(new_layer, color_mode=3)
with open('newfile.psd', 'wb') as fd:
new_psd.write(fd)
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
The text was updated successfully, but these errors were encountered:
Description
I'm trying to merge two PNG file into a PSD file, but the result showed that it failed to show the opacity attributes. I don't know if I failed to find a correct module to run this operation, or that I had inputed wrong attributes. If it's the case that I found a wrong module, can someone please show me the original source code that directly addresses alpha channels?
What I Did
The text was updated successfully, but these errors were encountered: