我正在尝试执行一个简单的操作。调整我已经在photoshop中加载的图像的大小。

这是我的代码

    psApp.Open(psdFiles[0])  # Opens the PSD
    awayActiveDoc = psApp.Application.ActiveDocument  # Get active document object

    #Set units to pixels.
    psApp.Preferences.RulerUnits = 1

    #Printing out a bunch of info for the loaded doc.
    print "\n Active document:", awayActiveDoc.name
    print " Initial Doc size:", int(awayActiveDoc.width), int(awayActiveDoc.height)
    print " Doc path:", awayActiveDoc.path
    print " Doc BitsPerChannel:", awayActiveDoc.BitsPerChannel

    awayActiveDoc.Flatten()
    awayActiveDoc.resizeImage("51%", "51%")


这是尝试调整图像大小时得到的非法操作。有任何想法吗?


  在第73行中输入文件“ e:\ py_projects \ py_crowd \ test2.py”
    awayActiveDoc.resizeImage(“ 51%”,“ 51%”)
  getattr中的文件“ C:\ Python27 \ Lib \ site-packages \ win32com \ client \ dynamic.py”,第511行
    ret = self.oleobj.Invoke(retEntry.dispid,0,invoke_type,1)
  
  pywintypes.com_error:(-2147352567,'发生异常。',(0,u'Adobe> Photoshop',u'非法参数',无,0,-2147024809),无)

最佳答案

这是语法错误。

awayActiveDoc.resizeImage("51%", "51%")


需要成为

awayActiveDoc.ResizeImage("51%", "51%")


用大写字母R

10-07 15:14