image_tinify 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 462c5a064c5fd1e96ad7e6116576061e42dc9018e68ab3ca0e93dd4c77b25ea6
4
- data.tar.gz: 332835bbcebbc1413a43cd4ec6592a2e0d66a91d78579ff8add7b3d3cb2baefe
3
+ metadata.gz: 511ab2be46434d57becaf337d643551fa8c87da1244ccbb6d5795e1cea4cd44a
4
+ data.tar.gz: 3350ffc65f92b0b50e6e7bb8fdc51ce0bbf7d4aa4c6661bb8ea2b6c30d0cc3b7
5
5
  SHA512:
6
- metadata.gz: aa2730445fea293aa9b3657fd63d56c66bea010eeedd60ee4e528d253c22df26045df87412b6c1ded789741b6ebf2d8e1956c26c6c17faad1d90223cb104751b
7
- data.tar.gz: 2314974dfff07209c8957a2b0c336a265a5b643664a5616d774b98a93f4e821b3954fb6993c60a11657a82d8432adea47f690e8e45f4f08feaeb6c73ae1ddd6e
6
+ metadata.gz: 39288cbb277b06f6606d893f7632bf0abf39dee45b9d3fb56526a4d5d786f002d2f745a34d16ea0b894f9b5260936c18e0ef88368e3aeb5f440e45ea90fcd1bc
7
+ data.tar.gz: b9bddbbe9a527c28ab3e93e037237b989bd406769965fd9c0c6782be8615e0a4876973107ece9c6ae418b59d7bcfe512df1119ebbb75e2227aee4eaa81a514b8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- image_tinify (1.0.0)
4
+ image_tinify (1.0.1)
5
5
  chunky_png (~> 1.3.11)
6
6
  claide (~> 1.0.3)
7
7
  tinify (~> 1.5.0)
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- chunky_png (1.3.11)
12
+ chunky_png (1.3.14)
13
13
  claide (1.0.3)
14
14
  httpclient (2.8.3)
15
15
  rake (12.3.2)
@@ -11,8 +11,9 @@ ImageTinify::show_version(argv)
11
11
 
12
12
  should_list = argv.arguments.include?('list')
13
13
  should_compress = argv.arguments.include?('compress')
14
+ should_mark = argv.arguments.include?('mark')
14
15
 
15
- ImageTinify::show_help if !(should_list || should_compress)
16
+ ImageTinify::show_help if !(should_list || should_compress || should_mark)
16
17
 
17
18
  key = argv.option('key')
18
19
  key ||= ImageTinify::random_key if should_compress
@@ -29,6 +30,8 @@ images = []
29
30
  uncompressed_images = []
30
31
  # 本次压缩的图片
31
32
  compress_images = []
33
+ # 本次标记的图片
34
+ markted_images = []
32
35
 
33
36
  # 获取所有图片
34
37
  image_tinify.find_all_images root, proc { |path|
@@ -42,18 +45,29 @@ image_tinify.find_uncompressed_images(images) { |path|
42
45
 
43
46
  begin
44
47
  uncompressed_images.each { |path|
48
+ rel_path = image_tinify.relative_path(path)
45
49
  if should_compress
46
50
  size_before = File.stat(path).size
51
+ puts "- Compressing #{rel_path}"
47
52
  if image_tinify.compress_image(path)
48
53
  compress_images << path
49
54
  image_tinify.mark_compressed(path)
50
55
  size_after = File.stat(path).size
51
56
  puts " 压缩成功, [#{size_before}] => [#{size_after}]"
57
+ puts " [WARNING] Size increased" if size_before < size_after
52
58
  else
53
59
  puts " 压缩失败"
54
60
  end
61
+ elsif should_mark
62
+ puts "- Marking #{rel_path}"
63
+ if image_tinify.mark_compressed(path)
64
+ puts " 标记为已压缩"
65
+ else
66
+ puts " 标记失败"
67
+ end
68
+ markted_images << path
55
69
  else
56
- puts path
70
+ puts "- Uncompressed #{rel_path}"
57
71
  end
58
72
  }
59
73
  rescue Exception => e
@@ -64,4 +78,5 @@ ensure
64
78
  puts " 图片总数: #{images.count}"
65
79
  puts " 未压缩: #{uncompressed_images.count}"
66
80
  puts " 本次压缩: #{compress_images.count}" if should_compress
81
+ puts " 本次标记: #{markted_images.count}" if should_mark
67
82
  end
@@ -14,6 +14,7 @@ module ImageTinify
14
14
 
15
15
  + list 查看所有未压缩的图片
16
16
  + compress 对未压缩的图片进行压缩,并标记为已压缩
17
+ + mark 直接标记一张图片为已压缩
17
18
 
18
19
  选项:
19
20
 
@@ -77,7 +77,6 @@ module ImageTinify
77
77
  # 压缩图片
78
78
  def compress_image(path)
79
79
  validate! unless validate?
80
- puts "- Compressing #{relative_path(path)}"
81
80
  Tinify.from_file(path).to_file(path)
82
81
  true
83
82
  end
@@ -1,3 +1,3 @@
1
1
  module ImageTinify
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_tinify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiangzhuoyi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2021-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chunky_png
@@ -78,7 +78,7 @@ homepage: http://code.kaipao.cc/ios-team/image_tinify
78
78
  licenses:
79
79
  - MIT
80
80
  metadata: {}
81
- post_install_message:
81
+ post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths:
84
84
  - lib
@@ -93,8 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubygems_version: 3.1.2
97
- signing_key:
96
+ rubygems_version: 3.0.8
97
+ signing_key:
98
98
  specification_version: 4
99
99
  summary: Compress image.
100
100
  test_files: []