webtoon / psd

Fast zero-dependency PSD parser for the web and Node.js

Home Page:https://webtoon.github.io/psd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I programatically add image to the layer?

karolis-stulgys-allhuman opened this issue · comments

So instead of me going to photopea, uploading psd file, selecting layer, adding an image, resizing to fit the layer, exporting to png...
I would like to do this programatically in javascript (server side or client side). I want to write a function that accepts psd file, image file and options. It should output a .png file. Am I in the right place? Can I do this with "webtoon"? I've found libraries like "psd.js" but still not sure how can I achieve that. Can anyone give me an example? Your help is very much appreciated!

karolis

were you able to do it then? because currently I am looking for the same thing and webtoon documentation does not provide anything about modifying the layer image.

me too

Hi, sorry about the late reply @karolis-stulgys-allhuman @jatinshrma @winderzhang

Unfortunately, modifying the contents of the PSD (e.g. adding or removing layers) is currently out of the scope of this library. Implementing such a feature would certainly benefit us and others, but updating the structure of a PSD file is an entirely different matter from parsing one. (For that matter, I believe PSD.js does not provide such capabilities, either.)

I suggest two options:

  1. ag-psd seems to support writing to PSD files, so I assume it supports modifying them, too.
  2. If your end goal is to produce a regular image (i.e. PNG) rather than a PSD file, you could extract individual layers from the PSD file (with @webtoon/psd) and combine them manually. You can either use the Canvas API (in browser) or one of the many image manipulation libraries for Node.js.

Hi, @pastelmind
I love @webtoon/psd.💕
I have a trouble in using this module(0.4.0). Please help me.... 🙏
Can I parse mask layer and apply it? Is it possible?
If yes, could you provide me the sample code or docs?
Regards.