Comments (5)
Writing out modified PSDs is not supported at this time, but is something I've been considering for awhile. There used to be rudimentary support for it, but it was removed due to bugginess and overall poor code.
from psd.rb.
Hi meltingice,
Thanks for coming back to me.
Do you think you could point me to a commit hash where it used to be roughly supported? I would be really happy to have a look at how it was done, even if rudimentary. I have checked quite many of psd-format-related projects and none of them support this. The closest I could get to using gimp CLI that can create layers but it doesn't support managing slices. Do you perhaps know any alternatives or projects that can write psd format?
On another note, I am sure you have dived into Photoshop format much more than I did and your input would be really helpful. My only requirement would be to modify slice names. It definitely doesn't seem "intuitive" in a primitive way as just modifying strings in .psd binary as no slice names come up as strings, and binwalk doesn't find any compressions in the .psd format. Do you know any articles or clear documentation that explains how Photoshop encodes slices and/or the strings? Every documentation that I found only refers to layers and not the slices. As you've developed this project, did you follow any specifications? It seems rather difficult to follow .psd format from code in general. Specification would be definitely much easier to follow, i.e. to explain what 'nodes' are in the format, etc.
Your project has been very helpful to me so far, I have used it for last few months to read .psd slices information, which I am really glad is supported.
Thanks a lot and apologises for many questions.
from psd.rb.
Unfortunately the feature to write out changes was removed years ago, so you're going to have to go back pretty far to find the code. I think if you go back to commits from 2013, you'll be able to find it. There is one project that comes to mind that can generate PSDs, but it's written in Obj-C and I think can only generate new PSDs, not modify existing ones. Probably not what you're looking for.
Regarding modifying slice names...
Slices are in the resources section of the PSD, which occurs after the header and before the layer data. Unfortunately, slices are a little messy. Depending on your version of Photoshop, they can be defined in one of two ways.
The first way, which is from older versions, is that the data is stored in a static structure that's read the same way every time. Here, the slice names are stored as unicode strings (UTF16-BE), which is probably why a simple grep of the binary did not show the slice names.
The latest way stores the slice data in a descriptor. Descriptors are dynamic data structures that can store a wide variety of data. In order to make data access more consistent and remove this burden of knowledge from the user, we actually normalize the slice data between the old and the new versions. Looking at this code, you can see how the data is stored in a more structured manner. Now... this means that modifying the slice name is even more complicated, because you'll need to be able to overwrite part of the descriptor in such a way that you don't break the document.
Adobe publishes part of the PSD file spec, although I have found it to be inaccurate in a couple of places. For the most part, it's an okay guide. There is also a C-based project called libpsd that has a wealth of good information about parsing PSDs. It really helped me get PSD.rb off the ground and helped me with some of the tricker parts.
Hope that helps!
from psd.rb.
Thank you. That helps a lot :-) I will definitely be taking a closer look at all the links over the next few days.
I had look before at the Obj-C project source, it may partially be what I need. You are also completely right about UTF16 encoding, strings --encoding=b file.psd
perfectly lists the layer and slice names, which is what I also needed.
That all being said, one last question about the psd-enginedata
project, is it only a parser for the Photoshop descriptors? If it could also write descriptors from the markdown, wouldn't it be exactly what I need if I understand this right?
Thanks.
from psd.rb.
So the psd-enginedata
project is actually for parsing the markup format that is used to store all of the data about text layers. The code that reads and parses descriptors is here.
from psd.rb.
Related Issues (20)
- Font sizes of a Usertext layer not getting matched after parsing the PSD file
- [Question] Exported Structure to PSD HOT 1
- Wrong bounds for `Shape` layer HOT 1
- ERROR: Error installing psd: ERROR: Failed to build gem native extension. HOT 4
- Way to correlate layer with scene number in imagemagick.
- Blending ranges
- Exported layer comp does not include clipping mask and adjustment layers
- How can I get the rotate angel in the psd
- undefined method `outset' for #<PSD::Slice> HOT 2
- Don't work with psd-enginedata v 1.1.1
- 'Layr', 'Lr16' and 'Lr32' start at See Layer info.
- Error saving Layer Comp as png
- layer.type.styles doesn't work HOT 2
- How to distinguish Groups from Artboards
- nokogiri newer version not supported HOT 1
- Is it possible for us to replace the text layer and export it ? HOT 1
- Is that gem used anymore? I see last commit is from past 2 years?
- Potential problem with rle encoding?
- Get boundary of each style applied to text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psd.rb.