imagetools 1.3.1 → 1.4.0

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: b165e7e85d7d0854577ab7a1f452ff4b3df9d87ea82890dcdda5f0550f969046
4
- data.tar.gz: e38ddf3c06d47997399fada92f2130460cfadb5558bb0f460b555e07684cb3cb
3
+ metadata.gz: c695900493f7e008bd7a71202f740d8cf7934017cc4dbd554102e52c45d68be5
4
+ data.tar.gz: 9d0085886aac557e3da673d47258a30bf5c8ebcee4d77ad641ce232e73c21bb1
5
5
  SHA512:
6
- metadata.gz: f16f40fdcb563715da0064a6c5a2ef9bd61ff2469f70d7e25760156b081ef950b8c5ea3608bcf773e96ba59b91314216ff7b995bfd94b6c784b10d3a2d61c9a0
7
- data.tar.gz: bea91193b72e52fda2954c19939dbf92ae479bec2a3029c6d4156f2d19714b01e343301ce8f205a1c27d9ece7a95b538f700379dc37cedc48c9b353fba1fda26
6
+ metadata.gz: 9a0c730e84290e6f18afa19c5446d98e75fee8a2966229812d7e372e6e3dd9e38909c5f6c447ef8af9c807645b936248b50086709cce7f7df301e02536b60aef
7
+ data.tar.gz: c3e99d26db139acc25fc259449e6ba7344c9e788bd595ad6744a408ff7e5da253d07f00dc0a57a8036e464dc8c6f3763f07327fb137dddfd2be49f7aa37bcadb
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- imagetools (1.3.1)
4
+ imagetools (1.4.0)
5
5
  rmagick (= 3.2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- minitest (5.14.4)
10
+ minitest (5.15.0)
11
11
  rake (13.0.6)
12
12
  rmagick (3.2.0)
13
13
 
@@ -61,6 +61,9 @@ module Imagetools
61
61
  PNG_SEARCH = /(.+)\.png/i
62
62
  PNG_REPLACE = '\1.jpg'
63
63
  JPG_SEARCH = /(.+)\.jpe?g/i
64
+ HEIC_SEARCH = /(.+)\.heic/i
65
+ HEIC_REPLACE = '\1.jpg'
66
+
64
67
  EXCLUDE_PAT = /^_/ # 先頭が"_"の場合は除外
65
68
 
66
69
  def self.run(argv)
@@ -142,6 +145,10 @@ EOM
142
145
  filename.sub(PNG_SEARCH, PNG_REPLACE)
143
146
  end
144
147
 
148
+ def self.replace_heic2jpg(filename)
149
+ filename.sub(HEIC_SEARCH, HEIC_REPLACE)
150
+ end
151
+
145
152
  def self.match_exclude_image?(filename)
146
153
  filename =~ EXCLUDE_PAT
147
154
  end
@@ -172,10 +179,10 @@ EOM
172
179
  if exclude_image?(filepath)
173
180
  return
174
181
  end
175
-
176
182
  filepath = rename_image(filepath)
177
183
  filepath = webp2png(filepath)
178
184
  filepath = png2jpg(filepath)
185
+ filepath = heic2jpg(filepath)
179
186
  filepath = resize_jpg(filepath)
180
187
  filepath = rotate_jpg(filepath)
181
188
  filepath = compress_jpg(filepath)
@@ -239,6 +246,23 @@ EOM
239
246
  return topath
240
247
  end
241
248
 
249
+ def heic2jpg(filepath)
250
+ fromname = File.basename(filepath)
251
+ toname = self.class.replace_heic2jpg(fromname)
252
+ # puts "heic2jpg #{fromname}=>#{toname}"
253
+ return filepath if fromname == toname
254
+
255
+ dir = File.dirname(filepath)
256
+ topath = File.join(dir, toname)
257
+ puts "convert: #{filepath} => #{topath}"
258
+ # convert ~/Desktop/test.heic -o ~/Desktop/test.jpg
259
+ cmd = "#{CONVERT_CMD} \"#{filepath}\" \"#{topath}\""
260
+ if system(cmd)
261
+ FileUtils.rm(filepath)
262
+ end
263
+ return topath
264
+ end
265
+
242
266
  def resize_jpg(filepath)
243
267
  fromname = File.basename(filepath)
244
268
  unless fromname =~ JPG_SEARCH
@@ -1,3 +1,3 @@
1
1
  module Imagetools
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagetools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - src
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick