Skip to content

Failed to save a valid psd file #36

Description

@duncankam
  • psdwriter version:
  • Python version: 3.11
  • Operating System: mac

I

I simply open the file, call psd_to_nested_layers(), then call nested_layers_to_psd() and output the psd file.
The file may have still all the layers there, but it is no longer viewable with Preview, programmatically I can still find all layers there. Just a patch of black in Preview.

What I Did

import pytoshop
from pytoshop import enums
from pytoshop.user import nested_layers
from PIL import Image
import io

in_fpn = 'original.psd'
out_fpn = 'updated.psd'

def test_nested_layers_no_adjust(filename, outfilename):

with open(filename, 'rb') as fd:
    psd = pytoshop.read(fd)

    layers = nested_layers.psd_to_nested_layers(psd)
    
    for layer in layers:
      print(layer.name)

    psd2 = nested_layers.nested_layers_to_psd(layers, enums.ColorMode.rgb )

    with open(outfilename, 'wb')as fo:
       psd2.write(fo)

test_nested_layers_no_adjust(in_fpn, out_fpn)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions