PhotoshopAPI icon indicating copy to clipboard operation
PhotoshopAPI copied to clipboard

Text Layers

Open EmilDohne opened this issue 1 year ago • 20 comments

This is an issue to track the development of the implementation of text layers

EmilDohne avatar Nov 01 '24 10:11 EmilDohne

has there been no progress in editing text layers ? this was one feature I was looking forward to

algo-uno-10 avatar Jan 28 '25 04:01 algo-uno-10

A bit of both, I've been primarily working towards smart objects and adjustment layers which have so far added the following features:

  • descriptor parsing
  • rendering framework
  • compositing framework

So I do think its possible to once those are merged get this done fairly quickly as those are the main blocking points

EmilDohne avatar Jan 28 '25 06:01 EmilDohne

alright , I'll be happy to help in whatever way I can if needed

algo-uno-10 avatar Jan 28 '25 07:01 algo-uno-10

Thanks! Seeing as this and the smart objects have been requested while adjustment layers not so much I will prioritize text layers over adjustment layers for the .6 release

EmilDohne avatar Jan 28 '25 07:01 EmilDohne

Thanks! Seeing as this and the smart objects have been requested while adjustment layers not so much I will prioritize text layers over adjustment layers for the .6 release

wow thanks

algo-uno-10 avatar Jan 28 '25 07:01 algo-uno-10

Hey @algo-uno-10 now that smart objects are in the API I started looking into this and unfortunately, as with many things photoshop related this isnt as trivial as initially assumed.

Theres a couple of road blocks/features that are needed to make this work:

  • Parser for EngineData which seems to be some postscript derived dict-like format for storing the text information
  • Decoding the layer-local and global text info (around 500 lines of variables for each of these encoded as EngineData
  • Reading these text properties
  • Writing them
  • Rendering the text to an image buffer
  • Implementing warps

Likely this will take a couple of months to reverse engineer so I first wanted to ask you what would be your intended use case so I can prioritize adding support for these step by step

EmilDohne avatar Feb 27 '25 18:02 EmilDohne

Recording for my own sake:

Replacing of text data seems to only matter if we do it on the global Txt2 Tagged block, this will make photoshop prompt you to redraw the image data. The others seem to have no effect on this

EmilDohne avatar Feb 28 '25 07:02 EmilDohne

Hey @algo-uno-10 now that smart objects are in the API I started looking into this and unfortunately, as with many things photoshop related this isnt as trivial as initially assumed.

Theres a couple of road blocks/features that are needed to make this work:

  • Parser for EngineData which seems to be some postscript derived dict-like format for storing the text information
  • Decoding the layer-local and global text info (around 500 lines of variables for each of these encoded as EngineData
  • Reading these text properties
  • Writing them
  • Rendering the text to an image buffer
  • Implementing warps

Likely this will take a couple of months to reverse engineer so I first wanted to ask you what would be your intended use case so I can prioritize adding support for these step by step

my intended usecase was : a .psd template having layers of texts images etc. all I want to do is edit the text inside the template programmatically . sry for late reply

algo-uno-10 avatar Mar 01 '25 14:03 algo-uno-10

No worries, would you need the text to be redrawn or would it be ok if photoshop gives a warning on open saying the layers are out of date?

EmilDohne avatar Mar 01 '25 15:03 EmilDohne

No worries, would you need the text to be redrawn or would it be ok if photoshop gives a warning on open saying the layers are out of date?

the last lib I used was ag-psd which did the same , the image had to be opened in photoshop and then exported . I was looking for text redraw and exported directed to image format programmatically

algo-uno-10 avatar Mar 03 '25 00:03 algo-uno-10

Thanks for the info, I'll look into how ag-psd did their text replacement first and work on the other stuff after. It's definitely planned to be able to export the image from it but it will likely take some time

EmilDohne avatar Mar 03 '25 06:03 EmilDohne

First of all, thanks for your hard work. I have another use case. I have a psd file that has both text layer and image layer. I only want to replace the data of the image layer and keep the text layer unchanged. However, after I replaced the image layer, I found that the text layer became an all-white pixel(image) layer, the text is all lost. Is there any way to solve this problem?

Thanks.

wellitecho avatar Apr 12 '25 09:04 wellitecho

Hey @wellitecho, unfortunately that is the 'expected' behaviour. We currently don't have roundtripping for text layers so they just get written out again as a generic layer rather than what they came in as. However I do think until we've got full support for all layers this would be a valuable thing to have and shouldn't be too complicated to implement (as we do parse the information and could just dump it back out again).

Do you mind creating a ticket to track this? FYI I am out until start of may on vacation so I'll only get around to it after that.

EmilDohne avatar Apr 12 '25 09:04 EmilDohne

@EmilDohne Thanks for your quick reply. I created #141 for this. If you think there is any problem, feel free to edit the issue.

wellitecho avatar Apr 12 '25 09:04 wellitecho

Hey @algo-uno-10 now that smart objects are in the API I started looking into this and unfortunately, as with many things photoshop related this isnt as trivial as initially assumed.

Theres a couple of road blocks/features that are needed to make this work:

  • Parser for EngineData which seems to be some postscript derived dict-like format for storing the text information
  • Decoding the layer-local and global text info (around 500 lines of variables for each of these encoded as EngineData
  • Reading these text properties
  • Writing them
  • Rendering the text to an image buffer
  • Implementing warps

Likely this will take a couple of months to reverse engineer so I first wanted to ask you what would be your intended use case so I can prioritize adding support for these step by step

Hey, i found this https://github.com/layervault/psd-enginedata Would this help? It's in ruby so it's kind of beyond my scope

Deathstroke751 avatar May 20 '25 12:05 Deathstroke751

Hey @Deathstroke751, thanks a lot for the link :) I had found that one myself as well and its definitely very helpful although I don't know any ruby either.

EmilDohne avatar May 24 '25 16:05 EmilDohne

Hi, I'm very much interested in being able to modify the text layers in a PSD. Context: in the Marvel Champions cardgame community we create fanmade cards in PSD format. I have a python code that reads them using psd-tools to extract the information from the different layers and save that to different databases (for online play for example). It works great as long as I just need to read a file... Next, I would love to be able to modify the text of a file to automatize stuff (like card number and more). psd-tools does not support text modification, and doesn't support some effects such as Outer Glow for example... I was hoping your library might help me but if I am correct the text layers are still not accessible, is that the case?

bertou avatar Jul 31 '25 13:07 bertou

Hi, I'm very much interested in being able to modify the text layers in a PSD. Context: in the Marvel Champions cardgame community we create fanmade cards in PSD format. I have a python code that reads them using psd-tools to extract the information from the different layers and save that to different databases (for online play for example). It works great as long as I just need to read a file... Next, I would love to be able to modify the text of a file to automatize stuff (like card number and more). psd-tools does not support text modification, and doesn't support some effects such as Outer Glow for example... I was hoping your library might help me but if I am correct the text layers are still not accessible, is that the case?

It's not that difficult a project, just use canvas or something similar

wayix avatar Aug 01 '25 21:08 wayix

@EmilDohne Hi, what difficulties are you facing now, maybe you need some help?

wayix avatar Aug 01 '25 21:08 wayix

Hey @bertou, thank you for being interested in the project! Unfortunately this is not yet possible in the PhotoshopAPI but is planned to come in the future. For the time being I would suggest writing a script in photoshop itself using something like this: https://github.com/loonghao/photoshop-python-api

@wayix Time mainly, I've started the investigation process but haven't got much further than that since I'm lacking the time currently to dedicate myself to such a big problem. If you have the time and capacity I would appreciate help with the implementation, the resources linked above are a good starting point. Keep in mind that this is a rather big undertaking which can also be split into components such as first adding basic read support and then expanding that

EmilDohne avatar Aug 08 '25 07:08 EmilDohne