Photopea is a free Photoshop alternative that lives in the browser. If you haven’t used it already, you should definitely give it a try! It’s fast, requires no installation and will feel very comfortable to anyone who is used to Photoshop’s interface.
The part I want to focus on is the scripting it supports – mainly how to make it generate a zip file with PNG images based on a template.

As in Photoshop, scripts are written in Javascript using an API for interacting with the elements in the document. The API can be a bit puzzling, so here are some common functions:
app.activeDocument.layerSets // get all folders in a document app.activeDocument.artLayers // get all layers in a document (not in folders) layer.visible = true/false // toggle layer visibility layer.textItem.contents = "" // set text to a text layer layer.translate(layer.bounds[0]-X, layer.bounds[1]-Y) // move layer to X, Y
I started experimenting with this because for our upcoming board-game we have data for 32 cards in Google Sheets – name, strength, abilities etc. Generating prototypes for printing by hand was cumbersome and error-prone. So I decided to automate it. Similarly you might generate business cards, invitations, etc.
The solution I came up with takes data from Google Sheets in JSON form (scripting in Google Sheets is for another blog post). Based on the data, it shows/hides some layers and changes the text in text layers.
Here are some utility functions:
function getLayer(s){ // finds layer by name var layers = app.activeDocument.layers; for(var i = 0; i < layers.length; i++ ){ if( layers[i].name == s ) return layers[i]; } return null; } function getLayerSet(s){ // finds folder by name var layers = app.activeDocument.layerSets; for(var i = 0; i < layers.length; i++ ){ if( layers[i].name == s ) return layers[i]; } return null; } function activateOnly(s, set){ // activates one layer in a folder set = set || app.activeDocument; var layers = set.artLayers; for(var i = 0; i < layers.length; i++ ){ layers[i].visible = layers[i].name == s; } }
For each data item, show the correct layers and text…
activateOnly( item.color +" border", getLayerSet("border") ); var namelayer = getLayer("Name Text"); namelayer.textItem.contents = item.name;

… and export it as PNG.
var opts = new ExportOptionsSaveForWeb(); opts.format = SaveDocumentType.PNG; opts.PNG8 = false; opts.quality = 100; pngFile = new File(item.folder+"/"+item.name+".png"); app.activeDocument.exportDocument(pngFile, ExportType.SAVEFORWEB, opts);
Saving this script in a jsx file, you can drag it to Photopea to run it.
After the script ends, it spits out a .zip file with all the exported images in a folder structure. On my machine it generates 32 high-res PNGs in about 12 seconds – much faster than Photoshop!
There are some limits on what you can do, for example I haven’t figured out how to change the color of only part of a text.
Hope you find this useful.
Hi,
Please can you give me a link/snippet for reading a google sheet from Photopea script.
I search and i find only this : https://fishtrone.wordpress.com/2019/05/14/connecting-unity-editor-to-google-sheets/
It’s about google-sheets BUT with UNINTY not Photopea.
Thanks in advance.
I don’t think I ever got around to that. The google sheet side should stay the same, just in photopea you have to make a GET request with javascript, which should be supported I think. If you figure it out, you should share your code! 🙂
Thanks for your reply.
In your post above you claim “The solution I came up with takes data from Google Sheets in JSON form (scripting in Google Sheets is for another blog post)”,
I Have not found how to do it, i’m newbie in javascript and photopea.
I make request in reddit/photopea, but no one answer still now.
Hey, here’s the code from our original sheet, https://pastebin.com/w6yA1mW1 it creates a button which you can click and it will output the json for the data range that is specified on line 159. Hope this helps