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

Layer renaming behaves different when duplicated inside Photoshop #22

Open
tappi287 opened this issue Jan 15, 2019 · 0 comments
Open

Layer renaming behaves different when duplicated inside Photoshop #22

tappi287 opened this issue Jan 15, 2019 · 0 comments

Comments

@tappi287
Copy link

  • psdwriter version: 1.2.1
  • Python version: 3.7.1
  • Operating System: OS X 10.11.6, Windows 10 17763

Description

Photoshop adds an copy suffix to layer names when duplicating layers. It doesn't do this when duplicating layers created with pytoshop. If a pytoshop layer is manually renamed in PS, the desired behaviour is restored.

I would like to help track the cause of this issue but have no idea where to start. The name itself seems to be created correctly as pascal string padded with 4 bytes. I can replicate this behaviour across versions CC 2014 to 2018 on OS X and Windows.

What I Did

""" Renaming issue when duplicating layers inside Photoshop example """
from pathlib import Path

import numpy as np
from pytoshop.enums import ColorChannel, ColorMode
from pytoshop.user import nested_layers

# Color channel types RGBA
CHANNEL_TYPES = [ColorChannel.red, ColorChannel.green, ColorChannel.blue, ColorChannel.transparency]

# Create Image Layer
layer = nested_layers.Image(name='Test_Layer', color_mode=ColorMode.rgb)

# Fill Layer with random image data
img_np = np.array(np.random.rand(256, 256, 3) * 255, dtype=np.uint8)

num_channels = range(0, img_np.shape[2])
for channel_type, channel_idx in zip(CHANNEL_TYPES, num_channels):
    layer.set_channel(channel_type, img_np[..., channel_idx])

# Create PsdFile from layer list
psd_obj = nested_layers.nested_layers_to_psd(layers=[layer], color_mode=ColorMode.rgb)

psd_file = Path(__file__).parent / 'test_psd.psd'

with open(psd_file, 'wb') as file:
    psd_obj.write(file)
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

1 participant