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

I make all layers is visible,then save a new psd file, the new psd file's size of width、height、top、and bottom is error. #8

Open
Tzeross opened this issue Apr 25, 2018 · 0 comments

Comments

@Tzeross
Copy link

Tzeross commented Apr 25, 2018

  • psdwriter version:
  • Python version: 3.6
  • Operating System: Win 7

Description

I make all layers is visible,then save a new psd file, the new psd file's size of width、height、top、and bottom is error.

What I Did

'''this is my code '''
#!/usr/bin/env python

-- coding: utf-8 --

import os
import pytoshop
from pytoshop.user import nested_layers

def changevisible(filename, dtype=0):
visible_status = False if dtype == 0 else True
tmp_name = filename + '.bak'
with open(filename, 'rb') as fd:
psd = pytoshop.PsdFile.read(fd)
print(psd.width, psd.height)
layers = nested_layers.psd_to_nested_layers(psd)
for layer in layers:
print(layer.name, layer.top, layer.right, layer.left, layer.bottom)
layer.visible = visible_status
psd2 = nested_layers.nested_layers_to_psd(layers, psd.color_mode)
with open(tmp_name, 'wb') as fd:
psd2.write(fd)
os.remove(filename)
os.rename(tmp_name, filename)

filename = r"C:\Users\admina\Desktop\1.psd"
changevisible(filename, 1)

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