Comments (5)
Hey. Just a heads up that this is still on my radar but I haven't gotten to it yet. Not sure how time sensitive it is for you.
from psd.
Hey there.
Text layers aren't current supported, but I'd love for them to be supported in psd
.
The first step would be to check the spec to find out how text is stored.
Followed by parsing out the data from the appropriate section.
So, it currently isn't possible in psd
, but it's definitely possible to support.
from psd.
@chinedufn I've never done something like this, but it seems really interesting. I've actually hit a bit of a snag and wondering you had any suggestions.
In the file src/sections/layer_and_mask_information_section/mod.rs
, at the bottom, I check if the key is TySh
and read all that info by doing (psuedocode):
cursor.read_2()?; // Version
cursor.read(48)?; // Transformation
cursor.read_2()?; // Text version
cursor.read_4()?; // Descriptor version
The text version returns [0, 50]
, while the descriptor version returns [0, 0, 0, 16]
, which seems correct?
From here I get into the actual structure and as it says, I read the unicode string, which seems to be just an empty string, at least in my psd:
cursor.read_unicode_string()?; // name from classID
After this, I read the classID, this is where I implement a simple yet exact replica of the described method into the cursor:
pub fn read_ascii_string(&mut self) -> Result<String, Error> {
let mut length = self.read_u32()?;
if length == 0 {
length = 4;
}
let mut result = String::new();
for _ in 0..length {
let bytes = self.read_u8()?;
result.push(bytes as char);
}
Ok(result)
}
cursor.read_ascii_string()?; // classID
I've implemented a little past this point, but it seems that when I call read_ascii_string
, it has a length of 21624 characters, the image below is what it ends up returning:
Any suggestions on what I could or am doing wrong?
from psd.
I'm excited that you're diving in here. I'm more than happy to help wherever I can.
Could you make a really simple, small PSD file with a text layer in it and then add it to the fixtures folder
Then add a text_layer.rs
to the integration tests folder along with a failing test case. (Let me know if you need any help on how to do this).
From there, if you can push up your code I can pull it and take a look and see if I notice anything.
Thanks for diving into this. I'm glad that it looks like you're close to having it working.
from psd.
@chinedufn https://github.com/ok-nick/psd
cargo test --test layer_and_mask_information_section text_layer -- --exact
The test is located in tests/layer_and_mast_information_section.rs
at the bottom.
from psd.
Related Issues (20)
- Cropping a layer based on it's content HOT 4
- Migrate to GitHub Actions
- Remove thiserror after API stabilizes
- Error: Index out of bounds HOT 1
- psd.group_by_id() expects vector index whereas group IDs range 1..n HOT 1
- Support deleting layers without HOT 4
- error[E0432]: unresolved import `virtual_node::DynClosure` HOT 1
- Wrong transparency HOT 1
- Unicode string may have no paddings HOT 3
- DescriptorStructure can occur inside an ImageResourcesBlock HOT 1
- No Timeline information HOT 2
- Layers outside of the bounding rect of the PSD HOT 2
- Get layer of sub-sub-sub...-groups HOT 1
- No overflow protection for `i32 as usize` in this crate
- InvalidChannel error
- I have a custom JSON format, how can I convert it to PSD and save it as a file? HOT 1
- Layer visibility is opposite
- index out of bounds HOT 1
- How to obtain the tree structure data of layers?
- cannot access `BlendMode` but PsdLayer.blend_mode() returns `BlendMode`.
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.