imagetools 1.4.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/runConfigurations.xml +10 -0
- data/.idea/workspace.xml +10 -14
- data/.ruby-version +1 -1
- data/Gemfile.lock +4 -4
- data/exe/imageblog +5 -0
- data/imagetools.gemspec +1 -1
- data/imagetools.iml +1 -1
- data/lib/imagetools/imageblog.rb +148 -0
- data/lib/imagetools/imageconcat.rb +12 -4
- data/lib/imagetools/imagefilter.rb +40 -25
- data/lib/imagetools/version.rb +1 -1
- data/sample/hugo_dst/1200x400.png +0 -0
- data/sample/hugo_dst/1200x800.png +0 -0
- data/sample/hugo_dst/600x200.png +0 -0
- data/sample/hugo_src/0000.png +0 -0
- data/sample/hugo_src/0001.png +0 -0
- data/sample/hugo_src/0002.png +0 -0
- data/test_imageblog.sh +2 -0
- metadata +21 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f128fc1b72a58b40adbbba6c9c078cd5005d14c230134692c6d9237c2a35bc54
|
4
|
+
data.tar.gz: 38f28d503272cd72386ceb7f67b0201f6431adbf861ddfac4e96787467140440
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45346fcff77ae87676bb73a1cf7d622dfbcc14e90cabf114e2d123e4792ab9b175808a4cb0eb9412db6f600984e8973158e1406e804704c70e5ff08477dbbad2
|
7
|
+
data.tar.gz: c2ef3862385e14409f88dbe169248d3f624e2fbfd789ea63ef679c1826ad119461dbde03a38912886cec06a24e21dc1d9e0438f13fe275006e9aab4028a6bdd7
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="RunConfigurationProducerService">
|
4
|
+
<option name="ignoredProducers">
|
5
|
+
<set>
|
6
|
+
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
7
|
+
</set>
|
8
|
+
</option>
|
9
|
+
</component>
|
10
|
+
</project>
|
data/.idea/workspace.xml
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
|
-
<list default="true" id="b197c64f-57f8-4389-ab8d-dc9fe3cb05ba" name="Default" comment=""
|
5
|
-
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
6
|
-
<change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
|
7
|
-
<change beforePath="$PROJECT_DIR$/imagetools.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/imagetools.gemspec" afterDir="false" />
|
8
|
-
<change beforePath="$PROJECT_DIR$/imagetools.iml" beforeDir="false" afterPath="$PROJECT_DIR$/imagetools.iml" afterDir="false" />
|
9
|
-
</list>
|
4
|
+
<list default="true" id="b197c64f-57f8-4389-ab8d-dc9fe3cb05ba" name="Default" comment="" />
|
10
5
|
<option name="SHOW_DIALOG" value="false" />
|
11
6
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
12
7
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
@@ -32,7 +27,6 @@
|
|
32
27
|
<component name="ProjectId" id="1YvZY4FKb8fv8Y6MWahnStNLEFS" />
|
33
28
|
<component name="ProjectViewState">
|
34
29
|
<option name="hideEmptyMiddlePackages" value="true" />
|
35
|
-
<option name="showExcludedFiles" value="true" />
|
36
30
|
<option name="showLibraryContents" value="true" />
|
37
31
|
</component>
|
38
32
|
<component name="PropertiesComponent">
|
@@ -42,12 +36,17 @@
|
|
42
36
|
<property name="MemberChooser.copyJavadoc" value="false" />
|
43
37
|
<property name="MemberChooser.showClasses" value="true" />
|
44
38
|
<property name="MemberChooser.sorted" value="false" />
|
39
|
+
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
40
|
+
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
45
41
|
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
|
46
42
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
47
43
|
<property name="aspect.path.notification.shown" value="true" />
|
48
44
|
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
49
45
|
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
50
46
|
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
47
|
+
<property name="project.structure.last.edited" value="Project" />
|
48
|
+
<property name="project.structure.proportion" value="0.0" />
|
49
|
+
<property name="project.structure.side.proportion" value="0.0" />
|
51
50
|
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
|
52
51
|
</component>
|
53
52
|
<component name="RunManager">
|
@@ -73,11 +72,12 @@
|
|
73
72
|
<RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
|
74
73
|
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
|
75
74
|
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
76
|
-
<EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov">
|
75
|
+
<EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" ENABLE_FORKED_COVERAGE="true">
|
77
76
|
<COVERAGE_PATTERN ENABLED="true">
|
78
77
|
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
79
78
|
</COVERAGE_PATTERN>
|
80
79
|
</EXTENSION>
|
80
|
+
<EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
|
81
81
|
<RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$PROJECT_DIR$/exe/iconcreator" />
|
82
82
|
<RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
|
83
83
|
<method v="2">
|
@@ -103,6 +103,7 @@
|
|
103
103
|
</method>
|
104
104
|
</configuration>
|
105
105
|
</component>
|
106
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
106
107
|
<component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" RAKE_SPRING_PRE_LOADER_OPTION="false" RAILS_SPRING_PRE_LOADER_OPTION="false" />
|
107
108
|
<component name="SvnConfiguration">
|
108
109
|
<configuration />
|
@@ -115,6 +116,7 @@
|
|
115
116
|
<updated>1570340432394</updated>
|
116
117
|
<workItem from="1570340436196" duration="217000" />
|
117
118
|
<workItem from="1583825074054" duration="96000" />
|
119
|
+
<workItem from="1646719315550" duration="10000" />
|
118
120
|
</task>
|
119
121
|
<servers />
|
120
122
|
</component>
|
@@ -131,12 +133,6 @@
|
|
131
133
|
</list>
|
132
134
|
</option>
|
133
135
|
</component>
|
134
|
-
<component name="WindowStateProjectService">
|
135
|
-
<state x="100" y="123" width="1720" height="977" key="DiffContextDialog" timestamp="1583825160786">
|
136
|
-
<screen x="0" y="23" width="1920" height="1177" />
|
137
|
-
</state>
|
138
|
-
<state x="100" y="123" width="1720" height="977" key="DiffContextDialog/-1920.23.1920.1177/0.23.1920.1177@0.23.1920.1177" timestamp="1583825160786" />
|
139
|
-
</component>
|
140
136
|
<component name="masterDetails">
|
141
137
|
<states>
|
142
138
|
<state key="ProjectJDKs.UI">
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.2
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
imagetools (1.
|
5
|
-
rmagick
|
4
|
+
imagetools (1.5.2)
|
5
|
+
rmagick
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
minitest (5.15.0)
|
11
11
|
rake (13.0.6)
|
12
|
-
rmagick (
|
12
|
+
rmagick (4.2.4)
|
13
13
|
|
14
14
|
PLATFORMS
|
15
15
|
ruby
|
@@ -21,4 +21,4 @@ DEPENDENCIES
|
|
21
21
|
rake (~> 13.0)
|
22
22
|
|
23
23
|
BUNDLED WITH
|
24
|
-
2.
|
24
|
+
2.3.8
|
data/exe/imageblog
ADDED
data/imagetools.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.bindir = "exe"
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
|
-
spec.add_dependency "rmagick"
|
32
|
+
spec.add_dependency "rmagick"
|
33
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
34
|
spec.add_development_dependency "rake", "~> 13.0"
|
35
35
|
spec.add_development_dependency "minitest", "~> 5.0"
|
data/imagetools.iml
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
4
|
<exclude-output />
|
5
5
|
<content url="file://$MODULE_DIR$" />
|
6
|
-
<orderEntry type="jdk" jdkName="rbenv:
|
6
|
+
<orderEntry type="jdk" jdkName="rbenv: 3.0.2" jdkType="RUBY_SDK" />
|
7
7
|
<orderEntry type="sourceFolder" forTests="false" />
|
8
8
|
<orderEntry type="module-library">
|
9
9
|
<library name="minitest (vbundled(5.14.0)) [path][gem]" type="rubylib">
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# imagehugo: hugo用の画像処理。リネームとサムネイル&アイキャッチ画像の生成。
|
3
|
+
|
4
|
+
require 'imagetools/version'
|
5
|
+
require 'imagetools/imagefilter'
|
6
|
+
require 'rmagick'
|
7
|
+
require 'optparse'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
module Imagetools
|
11
|
+
class ImageItem
|
12
|
+
attr_accessor :srcfile, :dstfile, :outfile
|
13
|
+
def to_s
|
14
|
+
"#{srcfile}=>#{dstfile}=>#{outfile}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Imageblog
|
19
|
+
def self.run(argv)
|
20
|
+
STDOUT.sync = true
|
21
|
+
opts = {}
|
22
|
+
opt = OptionParser.new(argv)
|
23
|
+
opt.version = VERSION
|
24
|
+
opt.banner = "Usage: #{opt.program_name} [-h|--help] <dir> or <image1 image2 image3 ...>"
|
25
|
+
opt.separator('')
|
26
|
+
opt.separator("Examples:")
|
27
|
+
opt.separator(" #{opt.program_name} ~/tmp # concat two recent IMG_*jpg images.")
|
28
|
+
opt.separator(" #{opt.program_name} image1.jpg image2.jpg image3.jpg # concat specified images.")
|
29
|
+
opt.separator('')
|
30
|
+
opt.separator("Options:")
|
31
|
+
opt.on_head('-h', '--help', 'Show this message') do |v|
|
32
|
+
puts opt.help
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
opt.on('-v', '--verbose', 'Verbose message') {|v| opts[:v] = v}
|
36
|
+
opt.on('--dry-run', 'Message only') {|v| opts[:dry_run] = v}
|
37
|
+
opt.on('-o OUTDIR', '--output=OUTDIR', 'Output dir') {|v| opts[:o] = v}
|
38
|
+
opt.on('-n NUM', '--number=NUM', 'Process image number') {|v| opts[:n] = v.to_i}
|
39
|
+
opt.on('-b BASENAME', '--base=BASENAME', 'Output file basename') {|v| opts[:b] = v}
|
40
|
+
opt.parse!(argv)
|
41
|
+
opts[:b] ||= Time.now.strftime("%Y%m%d")
|
42
|
+
dir, image_files = get_image_files(opts, argv)
|
43
|
+
if image_files.size == 0
|
44
|
+
puts opt.help
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
command = Imageblog.new(opts)
|
48
|
+
command.run(dir, image_files)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.get_image_files(opts, argv)
|
52
|
+
image_files = []
|
53
|
+
# ディレクトリが処理対象かどうかを決める
|
54
|
+
dir = nil
|
55
|
+
if argv.size == 1
|
56
|
+
# 引き数が1個の場合は最初の引き数
|
57
|
+
path = File.expand_path(argv[0])
|
58
|
+
if FileTest.directory?(path)
|
59
|
+
dir = path
|
60
|
+
end
|
61
|
+
elsif argv.size == 0
|
62
|
+
# 引き数がない場合カレントディレクトリ
|
63
|
+
dir = File.expand_path('.')
|
64
|
+
end
|
65
|
+
if dir
|
66
|
+
concat_number = opts[:n] || 2
|
67
|
+
# ディレクトリが指定されていた場合、指定ディレクトリ内のIMG_ファイルの最新n個を対象とする
|
68
|
+
# 最新の基準は(ファイル名基準)
|
69
|
+
match_files = Dir.glob("#{dir}/*.{jpg,jpeg,png}", File::FNM_CASEFOLD).sort
|
70
|
+
# match_files.sort {|a, b|
|
71
|
+
# File.mtime(a) <=> File.mtime(b)
|
72
|
+
# }
|
73
|
+
# 後ろからn個を取得(小さい方の数とする)
|
74
|
+
count = [match_files.size, concat_number].min
|
75
|
+
image_files = match_files[-count..-1]
|
76
|
+
else
|
77
|
+
# それ以外は指定された引き数を全て対象とする
|
78
|
+
argv.each do |arg|
|
79
|
+
arg = File.expand_path(arg)
|
80
|
+
dir = File.dirname(arg)
|
81
|
+
if FileTest.file?(arg) && (arg =~ /\.jpe?g$/i || arg =~ /\.png/i)
|
82
|
+
image_files << arg
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
return dir, image_files
|
87
|
+
end
|
88
|
+
|
89
|
+
def initialize(opts)
|
90
|
+
@opts = opts
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def run(dir, image_files)
|
95
|
+
outdir = dir
|
96
|
+
if @opts[:o]
|
97
|
+
outdir = @opts[:o]
|
98
|
+
end
|
99
|
+
rename_images(image_files, outdir)
|
100
|
+
# concat_images(image_files, output_path)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
def rename_images(image_files, outdir)
|
105
|
+
# サムネイルはhoge_0.jpg
|
106
|
+
# アイキャッチはhoge_1.jpg hoge_2.jpg以降が通常の画像
|
107
|
+
items = []
|
108
|
+
thumbnal_item = nil # hoge_0.jpgとする
|
109
|
+
image_files.each_with_index do |image_file, index|
|
110
|
+
item = ImageItem.new
|
111
|
+
item.srcfile = image_file
|
112
|
+
|
113
|
+
src_basename = File.basename(image_file)
|
114
|
+
extname = File.extname(src_basename)
|
115
|
+
dst_basename = @opts[:b]
|
116
|
+
|
117
|
+
item.dstfile = File.join(outdir, "#{dst_basename}_#{index + 1}#{extname}")
|
118
|
+
if index == 0
|
119
|
+
thumbnal_item = ImageItem.new
|
120
|
+
thumbnal_item.srcfile = image_file
|
121
|
+
thumbnal_item.dstfile = File.join(outdir, "#{dst_basename}_0#{extname}")
|
122
|
+
end
|
123
|
+
items << item
|
124
|
+
end
|
125
|
+
items.each do |item|
|
126
|
+
FileUtils.cp(item.srcfile, item.dstfile)
|
127
|
+
end
|
128
|
+
FileUtils.cp(thumbnal_item.srcfile, thumbnal_item.dstfile)
|
129
|
+
|
130
|
+
#フィルタ実行
|
131
|
+
config = Config.new
|
132
|
+
config.init_default
|
133
|
+
opts = {}
|
134
|
+
filter = Imagefilter.new(opts, config)
|
135
|
+
items.each do |item|
|
136
|
+
item.outfile = filter.run(item.dstfile)
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
# サムネイル
|
141
|
+
config.resize_width = 400
|
142
|
+
filter = Imagefilter.new(opts, config)
|
143
|
+
thumbnal_item.outfile = filter.run(thumbnal_item.dstfile)
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
@@ -26,7 +26,7 @@ module Imagetools
|
|
26
26
|
opt.on('-v', '--verbose', 'Verbose message') {|v| opts[:v] = v}
|
27
27
|
opt.on('--dry-run', 'Message only') {|v| opts[:dry_run] = v}
|
28
28
|
opt.on('-o OUTNAME', '--output=OUTNAME', 'Output file') {|v| opts[:o] = v}
|
29
|
-
opt.on('-n NUM', '--number=NUM', '
|
29
|
+
opt.on('-n NUM', '--number=NUM', 'Concat image number') {|v| opts[:n] = v.to_i}
|
30
30
|
opt.parse!(argv)
|
31
31
|
image_files = get_image_files(opts, argv)
|
32
32
|
if image_files.size < 2
|
@@ -89,14 +89,22 @@ module Imagetools
|
|
89
89
|
def concat_images(image_files, output_file)
|
90
90
|
puts image_files.join("+") + "=#{output_file}"
|
91
91
|
|
92
|
+
# 結果の画像リスト
|
92
93
|
result_image_list = Magick::ImageList.new
|
94
|
+
|
93
95
|
image_files.each do |image_file|
|
94
|
-
#
|
95
|
-
|
96
|
+
# 個別画像の背景色を白に変換
|
97
|
+
# 一気に行く方法がないので、ImageListを作成しbackground_colorとflatten_imagesを組み合わる。
|
98
|
+
# image_list = Magick::ImageList.new(image_file) {self.background_color = 'white'}
|
99
|
+
# 2022/03/24「passing a block without an image argument is deprecate」対策。 https://github.com/rmagick/rmagick/blob/main/CHANGELOG.md RMagick 4.2.0
|
100
|
+
image_list = Magick::ImageList.new(image_file) {|image| image.background_color = 'white'}
|
96
101
|
image = image_list.flatten_images
|
102
|
+
|
103
|
+
# 結果の画像リストに追加
|
97
104
|
result_image_list << image
|
98
105
|
end
|
99
|
-
|
106
|
+
|
107
|
+
#append(false)で横方向に結合
|
100
108
|
result = result_image_list.append(false)
|
101
109
|
|
102
110
|
width = result.columns
|
@@ -9,20 +9,45 @@ module Imagetools
|
|
9
9
|
class Config
|
10
10
|
FILENAME_SEARCH = 's (\d+)-(\d+)-(\d+) (\d+)\.(\d+)\.(\d+)'
|
11
11
|
FILENAME_REPLACE = 's_\1\2\3_\4\5\6'
|
12
|
+
RESIZE_WIDTH = 1280
|
13
|
+
|
14
|
+
def self.create_from_yaml(yaml)
|
15
|
+
config = Config.new
|
16
|
+
config.filename_search1 = config_value(yaml, "filename", "search1", false)
|
17
|
+
config.filename_replace1 = config_value(yaml, "filename", "replace1", false)
|
18
|
+
config.filename_search2 = config_value(yaml, "filename", "search2", false)
|
19
|
+
config.filename_replace2 = config_value(yaml, "filename", "replace2", false)
|
20
|
+
config.filename_search3 = config_value(yaml, "filename", "search3", false)
|
21
|
+
config.filename_replace3 = config_value(yaml, "filename", "replace3", false)
|
22
|
+
config.resize_width = config_value(yaml, "resize", "width", false)
|
23
|
+
config.init_default
|
24
|
+
config
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def self.config_value(yaml, section, key, require)
|
29
|
+
return nil unless yaml
|
30
|
+
return nil unless yaml[section]
|
31
|
+
value = yaml[section][key]
|
32
|
+
if require && (value.nil? || value.empty?)
|
33
|
+
raise RuntimeError, "#{section}:#{key}: is empty"
|
34
|
+
end
|
35
|
+
value
|
36
|
+
end
|
12
37
|
|
13
|
-
def initialize
|
14
|
-
@yaml = yaml
|
15
|
-
@filename_search1 = config_value("filename", "search1", false) || FILENAME_SEARCH
|
16
|
-
@filename_replace1 = config_value("filename", "replace1", false) || FILENAME_REPLACE
|
17
|
-
@filename_search2 = config_value("filename", "search2", false)
|
18
|
-
@filename_replace2 = config_value("filename", "replace2", false)
|
19
|
-
@filename_search3 = config_value("filename", "search3", false)
|
20
|
-
@filename_replace3 = config_value("filename", "replace3", false)
|
38
|
+
def initialize
|
21
39
|
end
|
22
40
|
|
23
|
-
|
24
|
-
|
25
|
-
|
41
|
+
def init_default
|
42
|
+
@filename_search1 ||= FILENAME_SEARCH
|
43
|
+
@filename_replace1 ||= FILENAME_REPLACE
|
44
|
+
@resize_width ||= RESIZE_WIDTH
|
45
|
+
end
|
46
|
+
|
47
|
+
attr_accessor :filename_search1, :filename_replace1,
|
48
|
+
:filename_search2, :filename_replace2,
|
49
|
+
:filename_search3, :filename_replace3
|
50
|
+
attr_accessor :resize_width
|
26
51
|
|
27
52
|
def filename_patterns
|
28
53
|
[
|
@@ -31,16 +56,6 @@ module Imagetools
|
|
31
56
|
[@filename_search3, @filename_replace3],
|
32
57
|
]
|
33
58
|
end
|
34
|
-
|
35
|
-
private
|
36
|
-
def config_value(section, key, require)
|
37
|
-
return nil unless @yaml
|
38
|
-
value = @yaml[section][key]
|
39
|
-
if require && (value.nil? || value.empty?)
|
40
|
-
raise RuntimeError, "#{section}:#{key}: is empty"
|
41
|
-
end
|
42
|
-
value
|
43
|
-
end
|
44
59
|
end
|
45
60
|
|
46
61
|
class Imagefilter
|
@@ -49,8 +64,7 @@ module Imagetools
|
|
49
64
|
|
50
65
|
CONVERT_CMD = "convert"
|
51
66
|
DWEBP_CMD = "dwebp"
|
52
|
-
|
53
|
-
RESIZE_CMD = "mogrify -background white -resize 1280x\\> "
|
67
|
+
RESIZE_CMD = "mogrify -background white -resize %dx\\> "
|
54
68
|
ROTATE_CMD = "exiftran -ai "
|
55
69
|
COMPRESS_CMD = "jpegoptim --strip-all --max=90 "
|
56
70
|
EXTERNAL_CMDS = [RESIZE_CMD, ROTATE_CMD, COMPRESS_CMD]
|
@@ -99,7 +113,7 @@ EOM
|
|
99
113
|
if FileTest.file?(config_file)
|
100
114
|
yaml = YAML.load_file(config_file)
|
101
115
|
end
|
102
|
-
config = Config.
|
116
|
+
config = Config.create_from_yaml(yaml)
|
103
117
|
if opts[:t]
|
104
118
|
ret = selftest
|
105
119
|
exit(ret)
|
@@ -269,7 +283,8 @@ EOM
|
|
269
283
|
return filepath
|
270
284
|
end
|
271
285
|
puts "resize: #{filepath}"
|
272
|
-
|
286
|
+
resize_cmd = sprintf(RESIZE_CMD, @config.resize_width)
|
287
|
+
cmd = "#{resize_cmd} \"#{filepath}\""
|
273
288
|
system(cmd)
|
274
289
|
return filepath
|
275
290
|
end
|
data/lib/imagetools/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test_imageblog.sh
ADDED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagetools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- src
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rmagick
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +72,7 @@ email:
|
|
72
72
|
executables:
|
73
73
|
- iconcreator
|
74
74
|
- iconextractor
|
75
|
+
- imageblog
|
75
76
|
- imageburst
|
76
77
|
- imageconcat
|
77
78
|
- imagefilter
|
@@ -86,6 +87,7 @@ files:
|
|
86
87
|
- ".idea/inspectionProfiles/Project_Default.xml"
|
87
88
|
- ".idea/misc.xml"
|
88
89
|
- ".idea/modules.xml"
|
90
|
+
- ".idea/runConfigurations.xml"
|
89
91
|
- ".idea/vcs.xml"
|
90
92
|
- ".idea/workspace.xml"
|
91
93
|
- ".ruby-version"
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- build.sh
|
103
105
|
- exe/iconcreator
|
104
106
|
- exe/iconextractor
|
107
|
+
- exe/imageblog
|
105
108
|
- exe/imageburst
|
106
109
|
- exe/imageconcat
|
107
110
|
- exe/imagefilter
|
@@ -113,6 +116,7 @@ files:
|
|
113
116
|
- lib/imagetools.rb
|
114
117
|
- lib/imagetools/iconcreator.rb
|
115
118
|
- lib/imagetools/iconextractor.rb
|
119
|
+
- lib/imagetools/imageblog.rb
|
116
120
|
- lib/imagetools/imageburst.rb
|
117
121
|
- lib/imagetools/imageconcat.rb
|
118
122
|
- lib/imagetools/imagefilter.rb
|
@@ -142,12 +146,19 @@ files:
|
|
142
146
|
- sample/demo/demo/Base.lproj/Main.storyboard
|
143
147
|
- sample/demo/demo/Info.plist
|
144
148
|
- sample/demo/demo/ViewController.swift
|
149
|
+
- sample/hugo_dst/1200x400.png
|
150
|
+
- sample/hugo_dst/1200x800.png
|
151
|
+
- sample/hugo_dst/600x200.png
|
152
|
+
- sample/hugo_src/0000.png
|
153
|
+
- sample/hugo_src/0001.png
|
154
|
+
- sample/hugo_src/0002.png
|
145
155
|
- sample/icon.png
|
146
156
|
- sample/icon.sketch
|
147
157
|
- sample_iconcreator.sh
|
148
158
|
- test.sh
|
149
159
|
- test_iconcreator.sh
|
150
160
|
- test_iconextractor.sh
|
161
|
+
- test_imageblog.sh
|
151
162
|
- test_imageburst.sh
|
152
163
|
- test_imageconcat.sh
|
153
164
|
- test_imagefilter.sh
|
@@ -156,7 +167,7 @@ homepage: ''
|
|
156
167
|
licenses:
|
157
168
|
- MIT
|
158
169
|
metadata: {}
|
159
|
-
post_install_message:
|
170
|
+
post_install_message:
|
160
171
|
rdoc_options: []
|
161
172
|
require_paths:
|
162
173
|
- lib
|
@@ -171,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
182
|
- !ruby/object:Gem::Version
|
172
183
|
version: '0'
|
173
184
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
175
|
-
signing_key:
|
185
|
+
rubygems_version: 3.2.22
|
186
|
+
signing_key:
|
176
187
|
specification_version: 4
|
177
188
|
summary: Image Tools.
|
178
189
|
test_files: []
|