mdboom / pytoshop

Library for reading and writing Photoshop PSD and PSB files
Other
118 stars 22 forks source link

Failed to save a valid psd file #36

Open duncankam opened 1 year ago

duncankam commented 1 year ago

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)

duncankam commented 1 year ago

After investigation, this issue is similar to #30.