comic_walker 0.2.0 → 0.2.1

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: 6a5cddb9273f468c064ce300cbe66a9ca1f87680
4
- data.tar.gz: a2f75342e60753047ab80894a5e4f52281a41396
3
+ metadata.gz: bc332a43582cb967395943b6013f0ab99fcf5fdd
4
+ data.tar.gz: 6069256b1d66ef11fadea09a3244b8d71ccc1511
5
5
  SHA512:
6
- metadata.gz: 3002a2c97d87584ef29cc9c620d23abb58095a2df5234058d6b5daef8287ce0a76ec5ed53c46d12f6934e858b59333818b955f25348089362ef425917267f713
7
- data.tar.gz: f7fa296b48bd74e0781458e753d90405e7c884540429e7378be8f49b29ebe3832b676e8c26c1d723da8aeaa622e10febdbf0fba0554a63aac97585546a5142d3
6
+ metadata.gz: 102121a8021d81e8e198bac79376c903d28519ae1809cac411cc0aad7f675f29d6030d5800576b4b59a363009e8ae5f5c2e93055b26b3314e065abdb3f140f47
7
+ data.tar.gz: acd044111e10b6f6e4268432b5bc5bc66da3670499bfb911389def51acd682c4267b4f82a26705e94513b98b665293f3600bb099993d07ca367ccc964e4788ac
@@ -1,3 +1,6 @@
1
+ # 0.2.1 (2014-04-19)
2
+ - Take account of dummy width and height (#2)
3
+
1
4
  # 0.2.0 (2014-04-13)
2
5
  - Rename to `save` subcommand.
3
6
  - Add `contents` subcommand.
@@ -87,9 +87,6 @@ module ComicWalker
87
87
  when 'configuration_pack.json'
88
88
  config = JSON.parse(zip.read)
89
89
  decoder = ItemDecoder.new(config)
90
- config['configuration']['contents'].each do |content|
91
- pages[content['index']-1] = content['file']
92
- end
93
90
  when /end_layer\.json/
94
91
  begin
95
92
  pp EndLayerDecoder.new(license.key).decode(zip.read)
@@ -102,13 +99,13 @@ module ComicWalker
102
99
  end
103
100
 
104
101
  img_dir = Pathname.new(title).join(cid).tap(&:mkpath)
105
- pages.each.with_index do |file, i|
102
+ decoder.pages.each.with_index do |file, i|
106
103
  dat_path = Pathname.new(file).join('0.dat')
107
104
  data = items[dat_path.to_s]
108
105
  img_fname = dat_path.parent.basename.sub_ext('.jpg')
109
106
  img_path = img_dir.join(sprintf('%03d_%s', i, img_fname))
110
107
  puts "#{dat_path} -> #{img_path}"
111
- decoder.decode(dat_path, img_path, data)
108
+ decoder.decode(file, dat_path, img_path, data)
112
109
  end
113
110
  end
114
111
  end
@@ -3,6 +3,8 @@ require 'comic_walker/item_decoder/unknown'
3
3
 
4
4
  module ComicWalker
5
5
  class ItemDecoder
6
+ attr_reader :pages
7
+
6
8
  def initialize(configuration_pack)
7
9
  fname = '0.dat'
8
10
  ct = configuration_pack['ct']
@@ -11,9 +13,17 @@ module ComicWalker
11
13
  @key1 = (ct + st + fname).unpack('C*')
12
14
  @key2 = (ct + fname + et).unpack('C*')
13
15
  @key3 = (fname + st + et).unpack('C*')
16
+ @pages = []
17
+ configuration_pack['configuration']['contents'].each do |content|
18
+ pages[content['index']-1] = content['file']
19
+ end
20
+ @file_info = {}
21
+ @pages.each do |file|
22
+ @file_info[file] = configuration_pack[file]
23
+ end
14
24
  end
15
25
 
16
- def decode(dat_path, img_path, b64data)
26
+ def decode(file, dat_path, img_path, b64data)
17
27
  bs = 128
18
28
  hs = 1024
19
29
  blob = Unknown.finish(@key1, hs,
@@ -27,11 +37,14 @@ module ComicWalker
27
37
  src = Magick::Image.from_blob(blob).first
28
38
  width = src.columns
29
39
  height = src.rows
40
+ page_info = @file_info[file]['FileLinkInfo']['PageLinkInfoList'].first['Page']
41
+ dummy_height = page_info['DummyHeight']
42
+ dummy_width = page_info['DummyWidth']
30
43
  t = dat_path.sub_ext('').to_s.chars.inject(0) { |acc, c| acc + c.ord }
31
44
  pat = t%4 + 1
32
45
  moves = Unknown.calculate_moves(width, height, 64, 64, pat)
33
46
 
34
- dst = Magick::Image.new(width, height)
47
+ dst = Magick::Image.new(width - dummy_width, height - dummy_height)
35
48
  dst.format = 'jpeg'
36
49
  moves.each do |move|
37
50
  crop = src.excerpt(move[:destX], move[:destY], move[:width], move[:height])
@@ -1,5 +1,5 @@
1
1
  module ComicWalker
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
 
4
4
  VIEWER_VERSION = "1.0.2_2014-03-20"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comic_walker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler