Skip to main content

基本功能

获取字体信息

import photoshop
from photoshop import Session

app = photoshop.api.Application()
app.load('test.psd')

for i in app.documents:
print('修改前图层名称:', i.artLayers[0].textItem)
# print("修改前文字内容:", i.artLayers[0].textItem.contents)
print("修改前文字字体:", i.artLayers[0].textItem.font)

# print("修改前文字颜色:", i.artLayers[0].textItem.color.rgb)
print("修改前文字大小:", i.artLayers[0].textItem.size)
# print("修改前文字位置:", i.artLayers[0].textItem.position)

# i.artLayers[0].textItem.font = '2019ProBowl'
# i.artLayers[0].textItem.size = 300

# print('修改后文字为: 020')
# i.artLayers[0].textItem.contents = '020'
print("修改后文字大小:", i.artLayers[0].textItem.size)
# print("修改后文字位置:", i.artLayers[0].textItem.position)
# i.artLayers[0].textItem.font = u'Bodoni MT'

# i.artLayers[0].textItem.size = 300
print("修改前文字字体:", i.artLayers[0].textItem.font)

# with Session(target, action="open") as ps:
# ps.echo(ps.active_document.name)
# docRef = ps.app.activeDocument

# textlayer = ps.active_document.artLayers.getByName('textlayer')
# print('psd文件信息:')
# print('psd文件尺寸:', f'({docRef.width}, {docRef.height})')

# print('\n文字图层[textlayer]信息:')
# print("文字内容:", textlayer.textItem.contents)
# print("文字颜色:", textlayer.textItem.color.rgb)
# print("文字大小:", textlayer.textItem.size)
# print("文字位置:", textlayer.textItem.position)
# print("文字对象:", textlayer.textItem.font)


# # print("文字对象:", textlayer.textItem.text_font)
# # print("文字对象:", textlayer.textItem.parent.font)
# print('文件对象: ', dir(textlayer.textItem))

# new_contents = 'capsion'
# # textlayer.textItem.contents = new_contents
# # print("修改文字内容为: ", new_contents)

获取图层信息