Giter VIP home page Giter VIP logo

Comments (11)

meltingice avatar meltingice commented on August 22, 2024

There is now as of v0.4.0 :)

PSD.open('examples/images/example.psd') do
  puts resources[:layer_comps].data
end

# Outputs
{:class=>{:name=>"", :id=>"CompList"},
 "list"=>
  [{:class=>{:name=>"", :id=>"Comp"},
    "Nm  "=>"Version A",
    "compID"=>692243163,
    "capturedInfo"=>1},
   {:class=>{:name=>"", :id=>"Comp"},
    "Nm  "=>"Version B",
    "compID"=>725235304,
    "capturedInfo"=>1},
   {:class=>{:name=>"", :id=>"Comp"},
    "Nm  "=>"Version C",
    "compID"=>730932877,
    "capturedInfo"=>1}]}

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024

I should add that, while it's now possible to get the layer comp names, I haven't discovered how to get the layers associated with each comp yet. Hopefully soon.

from psd.rb.

bromanko avatar bromanko commented on August 22, 2024

Thanks meltingice! I'll keep an eye out for it.

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024

Reopening this because I just discovered, with 98% certainty, where the layer comp data is. It's hidden within the shmd layer info block. According to the spec, there is a variable amount of "undocumented data" at the end of the shmd block. Inspecting this data reveals a Descriptor that contains a list named compList. This compList holds the IDs of the layer comps to which the layer belongs.

Working on it now.

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024
{:class=>{:name=>"", :id=>"null"},
 "origFXRefPoint"=>
  {:class=>{:name=>"", :id=>"null"}, "Hrzn"=>0.0, "Vrtc"=>0.0},
 "LyrI"=>22,
 "layerSettings"=>
  [{:class=>{:name=>"", :id=>"null"},
    "enab"=>true,
    "blendOptions"=>{:class=>{:name=>"", :id=>"null"}, "Md  "=>"passThrough"},
    "compList"=>[692243163]},
   {:class=>{:name=>"", :id=>"null"}, "compList"=>[725235304]},
   {:class=>{:name=>"", :id=>"null"}, "enab"=>true, "compList"=>[730932877]},
   {:class=>{:name=>"", :id=>"null"}, "enab"=>true, "compList"=>[0]}]}

Was able to get the data parsed. Just need to organize it in a useful and easy to get fashion.

from psd.rb.

bromanko avatar bromanko commented on August 22, 2024

Fantastic! I think I can finally port some slow Photoshop plugin code. 👍

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024

Any chance you could divulge some information about your use case? Trying to figure out the best way to represent this data.

from psd.rb.

bromanko avatar bromanko commented on August 22, 2024

Sure. I currently generate redlines for our comps using a Photoshop script. It iterates over layer comps and creates a meta-data layer overlaying type and size information for various layers. Both a non-annotated and annotated PNG is then exported.

from psd.rb.

rvillas avatar rvillas commented on August 22, 2024

Oh!, Great!
I also have some slow scripts that use layer comps
👍

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024

So I've implemented a method for filtering based on layer comps:

tree = psd.tree.filter_by_comp('Version A')
tree.to_hash

The filter_by_comp method takes a comp ID, a comp name, or :last for the last document state. It returns a new tree that only contains the layers/groups that are included in the comp, so you can traverse it as needed.

Still need to write tests before I merge it into master.

from psd.rb.

meltingice avatar meltingice commented on August 22, 2024

Going to close this since layer comp information is now available. To access, use psd.layer_comps to get a hash of comps. You can also use the method from the previous post to generate a new tree based on a comp. Generating previews based on layer comps is hopefully coming soon.

from psd.rb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.