Migrating from version 1.7 to 1.8¶
There are major API changes in version 1.8.x.
Starting version 1.8.0, the package name is changed from psd_tools to psd_tools2.
import psd_tools from psd_tools import PSDImage
import psd_tools2 from psd_tools2 import PSDImage
File open method is changed from load to
psd = PSDImage.load(filename) with open(filename, 'rb') as f: psd = PSDImage.from_stream(f)
psd = PSDImage.open(filename) with open(filename, 'rb') as f: psd = PSDImage.open(f)
Children of PSDImage or Group is directly accessible by iterator or indexing.
for layer in group.layers: print(layer) first_child = group.layers
for layer in group: print(layer) first_child = group
Primary PIL export method is now
image = psd.as_PIL() layer_image = compose(layer) raw_layer_image = layer.as_PIL()
image = psd.compose() layer_image = layer.compose() raw_layer_image = layer.topil()