psd 3.3.1 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c7fc077ce3a8060aa8522a16838388a5a1930fa
4
- data.tar.gz: 07cd330663d7d94810c89f031d09bc41269610b3
3
+ metadata.gz: 17eeb855016ea89bc25453b66ed40793bc526012
4
+ data.tar.gz: d334945d94005f955b53ef559219d30dfa8109cd
5
5
  SHA512:
6
- metadata.gz: 0b6deef34cb5f66e8c079da3c72ffae7d2f8ad8baed3a91f1f8552d29a8bd6dcead464474bed1f715c60a1927e48e22ecd7583f80aaad580c95e536bc2e86532
7
- data.tar.gz: 5526dceb6954320be9ae3fd1d3a5a55b9820a8db16e68fea257e07f49f2f1207780010ec09a4cb2a73feca8c11895d112cb4dc16097fc3deff619c90268ebbfd
6
+ metadata.gz: 2040eb9b51beb8dadff64b723a8e09abc904c8cb4b3aab25b111b7ec08a88fcf0afb8f89eaa2aaa44d9d5e33a80f6641dae0c527116f08946df6714ff3912a6e
7
+ data.tar.gz: 99c0b1d6d7709c46ebcef097ba0bf2c1ee7c26fd83a7c0bab57e3d2d25f7b8f1cdddab99bb1f5a758e176cd55b55adeab990745d89483ce3b8cd900b9b0d5882
data/README.md CHANGED
@@ -237,6 +237,13 @@ psd.slice_by_id(2)
237
237
  psd.slices_by_name('Logo')
238
238
  ```
239
239
 
240
+ When you create a slice based off of a layer, Photoshop stores this relation in the file. If you have a slice that was created this way, you can easily get the associated layer.
241
+
242
+ ``` ruby
243
+ slice = psd.slices_by_name('Logo').first
244
+ slice.associated_layer #=> <PSD::Node::Layer>
245
+ ```
246
+
240
247
  Finally, you can export slices as PNGs.
241
248
 
242
249
  ``` ruby
@@ -104,4 +104,4 @@ class PSD
104
104
  Color.color_space_to_argb(color_space, color_component)
105
105
  end
106
106
  end
107
- end
107
+ end
@@ -16,12 +16,12 @@ class PSD
16
16
  @not_link = (tag & (0x01 << 1)) > 0
17
17
  @disable = (tag & (0x01 << 2)) > 0
18
18
 
19
- num_records = (@length - 8) / 26
20
-
19
+ # I haven't figured out yet why this is 10 and not 8.
20
+ num_records = (@length - 10) / 26
21
21
  @paths = []
22
22
  num_records.times do
23
23
  @paths << PathRecord.new(@file)
24
24
  end
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -54,7 +54,7 @@ class PSD
54
54
  resources: {
55
55
  layer_comps: @psd.layer_comps,
56
56
  guides: @psd.guides,
57
- slices: @psd.slices
57
+ slices: @psd.slices.map(&:to_hash)
58
58
  }
59
59
  }
60
60
  }
@@ -7,6 +7,7 @@ class PSD
7
7
 
8
8
  def initialize(psd, data)
9
9
  @psd = psd
10
+ @keys = data.keys
10
11
  data.each do |k, v|
11
12
  instance_variable_set("@#{k}", v)
12
13
  end
@@ -35,5 +36,9 @@ class PSD
35
36
  def save_as_png(file)
36
37
  @png.save(file, :fast_rgba)
37
38
  end
39
+
40
+ def to_hash
41
+ Hash[@keys.map { |k| [k.to_sym, self.send(k)] }]
42
+ end
38
43
  end
39
44
  end
@@ -1,3 +1,3 @@
1
1
  class PSD
2
- VERSION = "3.3.1"
2
+ VERSION = "3.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan LeFevre
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
12
+ date: 2015-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake