func init // checks installation Adobe Photoshop and adds references include("AdobePhotoshop") // initialize instance if(linked("Document") or not isdef("Name")) sys.add_var(this.name, 'ps.Document') end end func doNew(data) if(linked("Document") or not isdef("Name")) blk.println(this.codename, ' = ', this.make_new(data), ';') event("onComplete", this.codename) else event("onComplete", this.make_new(data)) end end func Document if(sys.is_linked(1) or not isdef("Name")) return(this.codename) else return(this.make_new()) end end func make_new(data) if(not isdef("RulerUnits")) blk.println(d("Photoshop", 20), '.Preferences.RulerUnits = ', sys.get_typed_field(0, 'RulerUnits', 14, 'ps.PsUnits'), ';') end return(d("Photoshop", 20) + '.Documents.Add(' + d("Width") + ', ' + d("Height") + ', ' + d("Resolution", 1, 'Type.Missing') + ', ' + d("FileName", 2, 'Type.Missing') + ', ' + sys.get_typed_field('Type.Missing', 'Mode', 14, 'ps.PsNewDocumentMode') + ', ' + sys.get_typed_field('Type.Missing', 'Fill', 14, 'ps.PsDocumentFill') + ', ' + d("Ratio", 7, 'Type.Missing') + ', ' + sys.get_typed_field('Type.Missing', 'BitsPerChannel', 14, 'ps.PsBitsPerChannelType') + ', ' + d("ColorProfile", 2, 'Type.Missing') + ')') end