使用 python 使用 Photoshop 进行基本的 tiff 处理
我需要编写一个执行以下操作的脚本:
# open a tiff
# get it's dpi, width, height and colorspace
# set the dpi, width, height and colorspace
# and then save the tiff out with no compression and no layers.
到目前为止,我已经得到:
from win32com.client.dynamic import Dispatch
ps = Dispatch( "Photoshop.Application" )
file_path = "C:\\Users\\me\\myImg.tif"
doc = ps.Open( file_path )
dpi = doc.Resolution
width = doc.Width # in cm
height = doc.Height # in cm
# up to here the code works, but then I try
doc.Resolution = 72
ps.ResizeImage( 120 , 120 )
ps.PsColorSpaceType( 3 ) # psSRGB
ps.TiffSaveOptions.ImageCompression = 1 # psNoTIFFCompression
ps.TiffSaveOptions.Layers = False
ps.Save()
# and this last section fails
请帮助,任何想法、提示、灵魂将不胜感激:D
I need to write a script that does the following:
# open a tiff
# get it's dpi, width, height and colorspace
# set the dpi, width, height and colorspace
# and then save the tiff out with no compression and no layers.
So far I've gotten:
from win32com.client.dynamic import Dispatch
ps = Dispatch( "Photoshop.Application" )
file_path = "C:\\Users\\me\\myImg.tif"
doc = ps.Open( file_path )
dpi = doc.Resolution
width = doc.Width # in cm
height = doc.Height # in cm
# up to here the code works, but then I try
doc.Resolution = 72
ps.ResizeImage( 120 , 120 )
ps.PsColorSpaceType( 3 ) # psSRGB
ps.TiffSaveOptions.ImageCompression = 1 # psNoTIFFCompression
ps.TiffSaveOptions.Layers = False
ps.Save()
# and this last section fails
Please help, any ideas, tips, soultions would be greatly appreciated :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过大量的谷歌搜索和一些试验和错误,然后是更多的试验和错误,我设法想出了下面的代码。
希望这可以帮助别人。
代码
After a lot of googeling and some trial and error and then even more trial and error I've managed to come up with the code below.
Hope this can help someone else.
Code