Generate assets layer syntax for Photoshop CC 2014 and above to render different image dimensions while maintaining aspect ratio
- Python 3+
- Adobe Photoshop CC 2014 and above
- Supported extensions: .jpg
- MacOS Sierra 10.x environment
- Other environments have not been tested
- Place image in same directory as the main script file (
generate-psd-assets.py). - Open terminal,
cdto the aforementioned directory and runpython generate-psd-assets.py. - Drag and drop the image into the terminal window and hit
enter. - If successful, output will be presented in the terminal window.
- Open Photoshop and with the image loaded.
- Go to
Photoshop > File > Generate > Image Assetsand ensure that it is checked. - Copy the output from the terminal window and paste it into the layer name in Photoshop.
- A folder with the generated assets will be created in the aforementioned directory. Done!
Q: Why can't i paste the output into the photoshop layer? There is a 255 character limit in the layer name. To fix this, use a shorter file name and try again.
Q: TypeError: 'NoneType' object is not subscriptable' This image cannot be used. Render it again. Use 'Save As' on Photoshop instead of 'Export > Save as Web' as certain metadata could have been lost during the export phase.
Q: I pasted the output into the layer name but nothing is happening Check your desktop for the generated folder. Also ensure that the 'Photoshop > File > Generate > Image Assets' option is checked.
Q: FileNotFoundError: [Errno 2] No such file or directory: 'foo.jpg' Please ensure that the image is in the same directory as this script.