def hello_world(): app = ps.Application() doc = app.documents.add() text_color = ps.SolidColor() text_color.rgb.green = 255 new_text_layer = doc.artLayers.add() new_text_layer.kind = ps.LayerKind.TextLayer new_text_layer.textItem.contents = 'Hello, World!' new_text_layer.textItem.position = [160, 167] new_text_layer.textItem.size = 40 new_text_layer.textItem.color = text_color options = ps.JPEGSaveOptions(quality=5) jpg = 'd:/hello_world.jpg' doc.saveAs(jpg, options, asCopy=True) app.doJavaScript(f'alert("save to jpg: {jpg}")')
"""This scripts demonstrates how to rotate a layer 45 degrees clockwise. References: https://github.com/lohriialo/photoshop-scripting-python/blob/master/RotateLayer.py """ import photoshop as ps app = ps.Application() if len(app.documents) > 0: print(app.activeDocument.activeLayer.typename) if not app.activeDocument.activeLayer.isBackgroundLayer: docRef = app.activeDocument layerRef = docRef.layers[0] layerRef.rotate(45.0) else: print("Operation cannot be performed on background layer") else: print("You must have at least one open document to run this script!")