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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/imagetools/imagefilter.rb +25 -1
- data/lib/imagetools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c695900493f7e008bd7a71202f740d8cf7934017cc4dbd554102e52c45d68be5
|
4
|
+
data.tar.gz: 9d0085886aac557e3da673d47258a30bf5c8ebcee4d77ad641ce232e73c21bb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0c730e84290e6f18afa19c5446d98e75fee8a2966229812d7e372e6e3dd9e38909c5f6c447ef8af9c807645b936248b50086709cce7f7df301e02536b60aef
|
7
|
+
data.tar.gz: c3e99d26db139acc25fc259449e6ba7344c9e788bd595ad6744a408ff7e5da253d07f00dc0a57a8036e464dc8c6f3763f07327fb137dddfd2be49f7aa37bcadb
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/imagetools/version.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2022-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|