libis-format 1.3.3 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libis/format/converter/image_converter.rb +164 -74
- data/lib/libis/format/converter/video_converter.rb +71 -24
- data/lib/libis/format/version.rb +1 -1
- data/libis-format.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6fcaac952f46961bb147aa74701c93116b9e62a33924c82c1c39e939e6fa8f5
|
4
|
+
data.tar.gz: 184bcd3c2ea39d8b0303bec9d68908bc33f2c3b9dd8872506f9b6e89cb57c618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abe4e81ed1e79777a0c6319f9b3105965bdcef05fffd18d1da93dd14b147271846f544b914b04b246dd2f884eb48909c0bd8d6ae88768dbfef6db5b5d5d37f5b
|
7
|
+
data.tar.gz: c52f3d3d0ca1b55c984321b4b92cd9f93835ebbfce5ae68ee96d2e545f6ca501aa355719b5394eedb23cfe78db21f6c938b51926860a9db2845407fc11900d6e
|
@@ -9,10 +9,6 @@ require 'fileutils'
|
|
9
9
|
MiniMagick.logger.level = ::Logger::UNKNOWN
|
10
10
|
|
11
11
|
MiniMagick.configure do |config|
|
12
|
-
# config.cli = :graphicsmagick
|
13
|
-
config.validate_on_create = false
|
14
|
-
config.validate_on_write = false
|
15
|
-
config.whiny = false
|
16
12
|
config.tmpdir = Libis::Format::Config[:tempdir] || Dir.tmpdir
|
17
13
|
end
|
18
14
|
|
@@ -90,65 +86,104 @@ module Libis
|
|
90
86
|
|
91
87
|
# Create or use a watermark image.
|
92
88
|
#
|
93
|
-
# The watermark options are:
|
94
|
-
# - file: watermark image to use
|
89
|
+
# The main watermark options are (use symbols):
|
95
90
|
# - text: text to create a watermark from
|
96
|
-
# -
|
97
|
-
# -
|
98
|
-
#
|
99
|
-
# - 1: 1 tile, so the watermark will be scaled up to fill the image
|
100
|
-
# - n > 1: minimum n tiles in both directions
|
101
|
-
# - n < 0: tile without scaling the watermark
|
102
|
-
# - size: same as tiles - for backwards compatibility
|
103
|
-
# - resize: fraction 0.0 - 1.0
|
104
|
-
# - gap: size of the gap between watermark instances. Fractions as percentage of widht/height. - default 0.2
|
105
|
-
# - opacity: opacity of the watermark (fraction 0.0 - 1.0) - default 0.1
|
106
|
-
# - gravity: center point of the overlay - default 'center'
|
107
|
-
# If both options are given, the file will be used as-is if it exists and is a valid image file. Otherwise the
|
108
|
-
# file will be created or overwritten with a newly created watermark image.
|
91
|
+
# - file: watermark image to use
|
92
|
+
# - image: same as above
|
93
|
+
# - banner: use side banner
|
109
94
|
#
|
110
|
-
#
|
111
|
-
# slanted by 30 degrees counter-clockwise.
|
95
|
+
# For each of these options above a dedicated option handler will be called
|
112
96
|
#
|
113
97
|
# @param [Hash] options Hash of options for watermark creation.
|
98
|
+
|
114
99
|
def watermark(options = {})
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
@wm_gap = ((options[:gap] || 0.2).to_f * 100).to_i
|
123
|
-
rotation = 360 - (options[:rotation] || 30).to_i
|
124
|
-
@wm_image = MiniMagick::Image.new(options[:file]) if options[:file]
|
125
|
-
return if @wm_image&.valid?
|
126
|
-
|
127
|
-
image = options[:file] || (Dir::Tmpname.create(%w[wm_image .png]) { |_| })
|
128
|
-
# noinspection RubyResolve
|
129
|
-
MiniMagick::Tool::Convert.new do |convert|
|
130
|
-
# noinspection RubyLiteralArrayInspection
|
131
|
-
convert.quiet
|
132
|
-
convert.background 'transparent'
|
133
|
-
convert.size('2000x2000')
|
134
|
-
convert.gravity 'Center'
|
135
|
-
convert.font('Helvetica').fill('black').pointsize(72) # .stroke('black').strokewidth(1)
|
136
|
-
convert << "label:#{text}"
|
137
|
-
convert.rotate rotation
|
138
|
-
convert.trim.repage.+ # rubocop:disable Lint/Void
|
139
|
-
convert << image
|
100
|
+
options.key_strings_to_symbols!
|
101
|
+
if options[:file] || options[:image]
|
102
|
+
watermark_image(options)
|
103
|
+
elsif options[:text]
|
104
|
+
watermark_text(options)
|
105
|
+
elsif options[:banner]
|
106
|
+
watermark_banner(options)
|
140
107
|
end
|
141
|
-
|
142
|
-
@wm_image = MiniMagick::Image.new(image)
|
143
|
-
else
|
144
|
-
@wm_image = MiniMagick::Image.open(image)
|
145
|
-
File.delete(image)
|
146
|
-
end
|
147
|
-
# noinspection RubyResolve
|
148
|
-
return if @wm_image.valid?
|
108
|
+
end
|
149
109
|
|
150
|
-
|
151
|
-
|
110
|
+
# Use an image as watermark
|
111
|
+
#
|
112
|
+
# Next to the :file or :image option, this enables the following options:
|
113
|
+
# - tiles: number of tiles of the watermark - default 4
|
114
|
+
# 0: no tiling, so only 1 watermark will be placed with the original size
|
115
|
+
# 1: 1 tile, so the watermark will be scaled up to fill the image
|
116
|
+
# n > 1: minimum n tiles in both directions
|
117
|
+
# n < 0: tile without scaling the watermark
|
118
|
+
# - size: same as tiles - for backwards compatibility
|
119
|
+
# - resize: fraction 0.0 - 1.0
|
120
|
+
# - gap: size of the gap between watermark instances. Fractions as percentage of widht/height. - default 0.2
|
121
|
+
# - opacity: opacity of the watermark (fraction 0.0 - 1.0) - default 0.1
|
122
|
+
# - gravity: center point of the overlay - default 'center'
|
123
|
+
# - composition: algorithm to use to compose both images - default modulate
|
124
|
+
def watermark_image(options = {})
|
125
|
+
options.key_strings_to_symbols!
|
126
|
+
@options[:watermark] = {command: 'image'}
|
127
|
+
@options[:watermark][:data] = options[:file] || options[:image]
|
128
|
+
@options[:watermark][:tiles] = (options[:tiles] || options[:size] || 4).to_i
|
129
|
+
@options[:watermark][:resize] = ((options[:resize]).to_f * 100).to_i if options[:resize]
|
130
|
+
@options[:watermark][:gap] = ((options[:gap] || 0.2).to_f * 100).to_i
|
131
|
+
@options[:watermark][:opacity] = ((options[:opacity] || 0.1).to_f * 100).to_i
|
132
|
+
@options[:watermark][:gravity] = options[:gravity] || 'center'
|
133
|
+
@options[:watermark][:composition] = options[:composition] || 'modulate'
|
134
|
+
@options[:watermark][:rotation] = 360 - (options[:rotation] || 30).to_i
|
135
|
+
end
|
136
|
+
|
137
|
+
# Use text as watermark
|
138
|
+
#
|
139
|
+
# Next to the :text option, this enables the following options:
|
140
|
+
# - tiles: number of tiles of the watermark - default 4
|
141
|
+
# 0: no tiling, so only 1 watermark will be placed with the original size
|
142
|
+
# 1: 1 tile, so the watermark will be scaled up to fill the image
|
143
|
+
# n > 1: minimum n tiles in both directions
|
144
|
+
# n < 0: tile without scaling the watermark
|
145
|
+
# - size: same as tiles - for backwards compatibility
|
146
|
+
# - resize: fraction 0.0 - 1.0
|
147
|
+
# - gap: size of the gap between watermark instances. Fractions as percentage of widht/height. - default 0.2
|
148
|
+
# - opacity: opacity of the watermark (fraction 0.0 - 1.0) - default 0.1
|
149
|
+
# - gravity: center point of the overlay - default 'center'
|
150
|
+
# - composition: algorithm to use to compose both images - default modulate
|
151
|
+
# - rotation: rotation of the text
|
152
|
+
def watermark_text(options = {})
|
153
|
+
options.key_strings_to_symbols!
|
154
|
+
@options[:watermark] = {command: 'text'}
|
155
|
+
@options[:watermark][:data] = options[:text] || '© LIBIS'
|
156
|
+
@options[:watermark][:tiles] = (options[:tiles] || options[:size] || 4).to_i
|
157
|
+
@options[:watermark][:resize] = ((options[:resize]).to_f * 100).to_i if options[:resize]
|
158
|
+
@options[:watermark][:gap] = ((options[:gap] || 0.2).to_f * 100).to_i
|
159
|
+
@options[:watermark][:opacity] = ((options[:opacity] || 0.1).to_f * 100).to_i
|
160
|
+
@options[:watermark][:gravity] = options[:gravity] || 'center'
|
161
|
+
@options[:watermark][:composition] = options[:composition] || 'modulate'
|
162
|
+
@options[:watermark][:rotation] = 360 - (options[:rotation] || 30).to_i
|
163
|
+
end
|
164
|
+
|
165
|
+
# Create a vertical banner to the right side of the image
|
166
|
+
#
|
167
|
+
# The banner options are:
|
168
|
+
# - banner: text to put in the banner
|
169
|
+
# - add_filename: append filename to the text (use any value to enable)
|
170
|
+
# - fontsize: size of the font (in points) (default: autoscale)
|
171
|
+
# - width: width of the banner (default: 3% of image height). Not including a border of 1/3 of the banner width
|
172
|
+
# - background_color_(red|green|blue): color components of background (default: rgb(84,190,233))
|
173
|
+
# - text_color_(red|green|blue): color components of background (default: rgb(255,255,255))
|
174
|
+
def watermark_banner(options = {})
|
175
|
+
options.key_strings_to_symbols!
|
176
|
+
@options[:watermark] = {command: 'banner'}
|
177
|
+
@options[:watermark][:data] = options[:banner] || '© LIBIS'
|
178
|
+
@options[:watermark][:add_filename] = !!options[:add_filename]
|
179
|
+
@options[:watermark][:size] = options[:fontsize] if options[:fontsize]
|
180
|
+
@options[:watermark][:width] = options[:width] if options[:width]
|
181
|
+
@options[:watermark][:background_red] = options[:background_color_red] || 84
|
182
|
+
@options[:watermark][:background_green] = options[:background_color_green] || 190
|
183
|
+
@options[:watermark][:background_blue] = options[:background_color_blue] || 233
|
184
|
+
@options[:watermark][:text_red] = options[:text_color_red] || 255
|
185
|
+
@options[:watermark][:text_green] = options[:text_color_green] || 255
|
186
|
+
@options[:watermark][:text_blue] = options[:text_color_blue] || 255
|
152
187
|
end
|
153
188
|
|
154
189
|
def convert(source, target, format, opts = {})
|
@@ -195,7 +230,7 @@ module Libis
|
|
195
230
|
convert_image(path, converted.path, format)
|
196
231
|
list << converted
|
197
232
|
end
|
198
|
-
MiniMagick
|
233
|
+
MiniMagick.convert do |b|
|
199
234
|
b.append unless self.class.multipage?(format)
|
200
235
|
converted_pages.each { |page| b << page.path }
|
201
236
|
b << target
|
@@ -210,34 +245,89 @@ module Libis
|
|
210
245
|
|
211
246
|
def convert_image(source, target, format)
|
212
247
|
image_info = nil
|
213
|
-
image_info = MiniMagick::Image::Info.new(source) { |b| b.quiet } if @wm_image # rubocop:disable Style/SymbolProc
|
214
248
|
|
215
|
-
MiniMagick
|
249
|
+
MiniMagick.convert do |convert|
|
250
|
+
# Make converter silent
|
216
251
|
convert.quiet if @quiet
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
252
|
+
|
253
|
+
# Build watermark image in buffer
|
254
|
+
wm = @options.delete(:watermark)
|
255
|
+
if wm
|
256
|
+
image_info = MiniMagick::Image::Info.new(source) { |b| b.quiet }
|
257
|
+
im_height = image_info['height']
|
258
|
+
im_width = image_info['width']
|
259
|
+
case wm[:command]
|
260
|
+
when 'text'
|
261
|
+
convert.background 'transparent'
|
262
|
+
convert.size('2000x2000')
|
263
|
+
convert.gravity 'Center'
|
264
|
+
convert.font('Helvetica').fill('black').pointsize(72) # .stroke('black').strokewidth(1)
|
265
|
+
convert << "label:#{wm[:data]}"
|
266
|
+
convert.rotate wm[:rotation]
|
267
|
+
convert.trim.repage.+ # rubocop:disable Lint/Void
|
268
|
+
convert.bordercolor('transparent').border("#{wm[:gap]}%") if wm[:gap].positive?
|
269
|
+
convert.filter('Lagrange')
|
270
|
+
convert.resize("#{im_width / wm[:tiles]}x#{im_height / wm[:tiles]}") if wm[:tiles].positive?
|
271
|
+
convert.resize("#{wm[:resize]}%") if wm[:resize]
|
272
|
+
when 'image'
|
273
|
+
convert << wm[:data]
|
274
|
+
convert.background 'transparent'
|
275
|
+
convert.bordercolor('transparent').border("#{wm[:gap]}%") if wm[:gap].positive?
|
276
|
+
convert.rotate wm[:rotation]
|
277
|
+
convert.filter('Lagrange')
|
278
|
+
convert.resize("#{im_width / wm[:tiles]}x#{im_height / wm[:tiles]}") if wm[:tiles].positive?
|
279
|
+
convert.resize("#{wm[:resize]}%") if wm[:resize]
|
280
|
+
when 'banner'
|
281
|
+
banner_width = wm[:width] || [0.03 * im_height, 20].max.round(0)
|
282
|
+
banner_border = banner_width / 3
|
283
|
+
convert.background "rgb(#{wm[:background_red]},#{wm[:background_green]},#{wm[:background_blue]})"
|
284
|
+
convert.size("#{im_height}x#{banner_width}")
|
285
|
+
convert.bordercolor "rgb(#{wm[:background_red]},#{wm[:background_green]},#{wm[:background_blue]})"
|
286
|
+
convert.border "0x#{banner_border}"
|
287
|
+
convert.fill "rgb(#{wm[:text_red]},#{wm[:text_green]},#{wm[:text_blue]})"
|
288
|
+
convert.font "Liberation-Sans"
|
289
|
+
convert.pointsize wm[:size] if wm[:size]
|
290
|
+
convert.gravity 'Center'
|
291
|
+
convert << "label:#{wm[:data]}#{wm[:add_filename] ? File.basename(source, '.*') : ''}"
|
292
|
+
end
|
293
|
+
|
294
|
+
# Save watermark image to buffer
|
223
295
|
convert.write('mpr:watermark').delete.+
|
296
|
+
|
297
|
+
# Restore canvas to source image size (workaround for IM bug when loading JP2K files)
|
298
|
+
convert.size("#{im_width}x#{im_height}")
|
224
299
|
end
|
225
300
|
|
226
|
-
|
301
|
+
# load source image
|
227
302
|
convert << source
|
303
|
+
|
304
|
+
# force flatten image if necessary
|
228
305
|
convert.flatten if @options[:flatten].nil? && format == :JPG
|
229
|
-
|
230
|
-
|
306
|
+
|
307
|
+
# add watermark image
|
308
|
+
if wm
|
309
|
+
if wm[:command] == 'banner'
|
310
|
+
convert.rotate '-90'
|
231
311
|
convert << 'mpr:watermark'
|
312
|
+
convert.rotate '180'
|
313
|
+
convert.append
|
314
|
+
convert.rotate '-90'
|
232
315
|
else
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
stack
|
237
|
-
|
316
|
+
if (0..1).include? wm[:tiles]
|
317
|
+
convert << 'mpr:watermark'
|
318
|
+
else
|
319
|
+
convert.stack do |stack|
|
320
|
+
stack.size("#{image_info['width']}x#{image_info['height']}")
|
321
|
+
stack << 'xc:transparent'
|
322
|
+
stack.tile('mpr:watermark')
|
323
|
+
stack.draw "rectangle 0,0,#{image_info['width']},#{image_info['height']}"
|
324
|
+
end
|
325
|
+
convert.compose(wm[:composition])
|
326
|
+
convert.gravity(wm[:gravity])
|
327
|
+
convert.define("compose:args=#{wm[:opacity]}%")
|
328
|
+
convert.composite
|
238
329
|
end
|
239
330
|
end
|
240
|
-
convert.compose(@wm_composition).gravity(@wm_gravity).define("compose:args=#{@wm_opacity}%").composite
|
241
331
|
end
|
242
332
|
|
243
333
|
@flags.each { |f, v| v.is_a?(TrueClass) ? convert.send(f).+ : convert.send(f) }
|
@@ -64,7 +64,7 @@ module Libis
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def constant_rate_factor(value)
|
67
|
-
@options[:
|
67
|
+
@options[:constant_rate_factor] = value.to_s
|
68
68
|
end
|
69
69
|
|
70
70
|
def frame_rate(value)
|
@@ -84,36 +84,66 @@ module Libis
|
|
84
84
|
@options[:watermark_image] = file
|
85
85
|
end
|
86
86
|
|
87
|
-
# @param [String] value
|
87
|
+
# @param [String] value Text for watermark. No watermark if nil (default)
|
88
88
|
def watermark_text(value)
|
89
|
-
@options[:watermark_text] = value
|
89
|
+
@options[:watermark_text] = value.to_s
|
90
90
|
end
|
91
91
|
|
92
|
-
# @param [
|
92
|
+
# @param [Boolean] value Should the filename be appended to the watermark text; use any value to enable
|
93
|
+
def watermark_text_add_filename(value)
|
94
|
+
@options[:watermark_text_add_filename] = !!value
|
95
|
+
end
|
96
|
+
|
97
|
+
# @param [String] value Font size for watermark text. Default: 10
|
93
98
|
# Note that the font is selected by the Config[:watermark_font] setting
|
94
99
|
def watermark_text_size(value)
|
95
|
-
@options[:watermark_text_size] = value.
|
100
|
+
@options[:watermark_text_size] = value.to_s
|
96
101
|
end
|
97
102
|
|
98
103
|
# @param [String] value Text color for the watermark text. Default: white
|
99
104
|
def watermark_text_color(value)
|
100
|
-
@options[:watermark_text_color] = value
|
105
|
+
@options[:watermark_text_color] = value.to_s
|
106
|
+
end
|
107
|
+
|
108
|
+
# @param [Integer] value Offset of the watermark text shadow. Used for both x and y offset; default: 1
|
109
|
+
# If the offset is set to 0, no shadow will be printed
|
110
|
+
def watermark_text_shadow_offset(value)
|
111
|
+
@options[:watermark_text_shadow_offset] = value.to_i
|
101
112
|
end
|
102
113
|
|
103
114
|
# @param [String] value Text color for the watermark text shadow. Default: black
|
104
115
|
def watermark_text_shadow_color(value)
|
105
|
-
@options[:watermark_text_shadow_color] = value
|
116
|
+
@options[:watermark_text_shadow_color] = value.to_s
|
106
117
|
end
|
107
118
|
|
108
|
-
# @param [Integer] value
|
109
|
-
|
110
|
-
|
111
|
-
|
119
|
+
# @param [Integer] value Enable/disable watermark text box. 1 to enanble, 0 to disable; default: 0
|
120
|
+
def watermark_text_box(value)
|
121
|
+
@options[:watermark_text_box] = value.to_i
|
122
|
+
end
|
123
|
+
|
124
|
+
# @param [String] value Color of the watermark text box; default: white
|
125
|
+
def watermark_text_box_color(value)
|
126
|
+
@options[:watermark_text_box_color] = value.to_s
|
127
|
+
end
|
128
|
+
|
129
|
+
# @param [String] value Border width of the watermark text box
|
130
|
+
def watermark_text_box_width(value)
|
131
|
+
@options[:watermark_text_box_width] = value.to_s
|
112
132
|
end
|
113
133
|
|
114
134
|
# @param [String] value one of 'bottom_left' (default), 'top_left', 'bottom_right', 'top_right', 'center'
|
115
135
|
def watermark_position(value)
|
116
|
-
@options[:watermark_position] = value
|
136
|
+
@options[:watermark_position] = value.to_s
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param [String] value offset x value for the text box. Default: 10
|
140
|
+
def watermark_offset_x(value)
|
141
|
+
@options[:watermark_offset_x] = value.to_s
|
142
|
+
end
|
143
|
+
|
144
|
+
# @param [String] value offset y value for the text box. Default: 10
|
145
|
+
def watermark_offset_y(value)
|
146
|
+
@options[:watermark_offset_y] = value.to_s
|
117
147
|
end
|
118
148
|
|
119
149
|
# @param [Number] value watermark opacity (0-1) with 0 = invisible and 1 = 100% opaque. Default: 0.5
|
@@ -121,6 +151,11 @@ module Libis
|
|
121
151
|
@options[:watermark_opacity] = value.to_f
|
122
152
|
end
|
123
153
|
|
154
|
+
# @param [Number] value watermark blending (0-1) with 0 = invisible and 1 = 100% opaque. Default: 0.5
|
155
|
+
def watermark_blending(value)
|
156
|
+
@options[:watermark_blending] = value.to_f
|
157
|
+
end
|
158
|
+
|
124
159
|
# @param [Boolean] value If set to true automatically selects optimal format for web viewing. Default: false
|
125
160
|
def web_stream(value)
|
126
161
|
return unless value
|
@@ -214,20 +249,30 @@ module Libis
|
|
214
249
|
if @options[:watermark_image]
|
215
250
|
opts[:filter] << '-i' << @options[:watermark_image] << '-filter_complex'
|
216
251
|
opts[:filter] << Kernel.format('[1:v]format=argb,colorchannelmixer=aa=%f[wm];[0:v][wm]overlay=%s',
|
217
|
-
@options[:watermark_opacity],
|
252
|
+
@options[:watermark_opacity], watermark_position_filter)
|
218
253
|
elsif @options[:watermark_text]
|
219
|
-
@options[:
|
254
|
+
wm_text = @options[:watermark_text]
|
255
|
+
wm_text += File.basename(source, '.*') if @options[:watermark_text_add_filename]
|
256
|
+
@options[:watermark_text_size] ||= '10'
|
220
257
|
@options[:watermark_text_color] ||= 'white'
|
221
258
|
@options[:watermark_text_shadow_color] ||= 'black'
|
222
259
|
@options[:watermark_text_shadow_offset] ||= 1
|
223
|
-
filter_text = Kernel.format("drawtext=text='%s':%s:fontfile=%s:fontsize=%
|
224
|
-
|
260
|
+
filter_text = Kernel.format("drawtext=text='%s':%s:fontfile=%s:fontsize=%s:fontcolor=%s@%f",
|
261
|
+
wm_text, watermark_position_filter(true), Config[:watermark_font],
|
225
262
|
@options[:watermark_text_size], @options[:watermark_text_color], @options[:watermark_opacity])
|
226
|
-
if (@options[:watermark_text_shadow_offset])
|
263
|
+
if !(@options[:watermark_text_shadow_offset] == 0)
|
227
264
|
filter_text += Kernel.format(':shadowcolor=%s@%f:shadowx=%d:shadowy=%d',
|
228
265
|
@options[:watermark_text_shadow_color], @options[:watermark_opacity],
|
229
266
|
@options[:watermark_text_shadow_offset], @options[:watermark_text_shadow_offset])
|
230
267
|
end
|
268
|
+
@options[:watermark_text_box] ||= 0
|
269
|
+
if (@options[:watermark_text_box]).positive?
|
270
|
+
filter_text += Kernel.format(':box=1:boxcolor=%s:boxborderw=%s',
|
271
|
+
@options[:watermark_text_box_color], @options[:watermark_text_box_width])
|
272
|
+
end
|
273
|
+
if (@options[:watermark_blending])
|
274
|
+
filter_text += Kernel.format(':alpha=%f', @options[:watermark_blending])
|
275
|
+
end
|
231
276
|
opts[:filter] << '-vf' << filter_text
|
232
277
|
end
|
233
278
|
opts[:output] << '-ac' << @options[:audio_channels] if @options[:audio_channels]
|
@@ -235,7 +280,7 @@ module Libis
|
|
235
280
|
opts[:output] << '-c:v' << @options[:video_codec] if @options[:video_codec]
|
236
281
|
opts[:output] << '-b:a' << @options[:audio_bitrate] if @options[:audio_bitrate]
|
237
282
|
opts[:output] << '-b:v' << @options[:video_bitrate] if @options[:video_bitrate]
|
238
|
-
opts[:output] << '-crf' << @options[:
|
283
|
+
opts[:output] << '-crf' << @options[:constant_rate_factor] if @options[:constant_rate_factor]
|
239
284
|
opts[:output] << '-map_metadata:g' << '0:g' # Copy global metadata
|
240
285
|
opts[:output] << '-map_metadata:s:a' << '0:s:a' # Copy audio metadata
|
241
286
|
opts[:output] << '-map_metadata:s:v' << '0:s:v' # Copy video metadata
|
@@ -261,20 +306,22 @@ module Libis
|
|
261
306
|
target
|
262
307
|
end
|
263
308
|
|
264
|
-
def
|
309
|
+
def watermark_position_filter(for_text = false)
|
310
|
+
margin_x = @options[:watermark_offset_x] || 10
|
311
|
+
margin_y = @options[:watermark_offset_y] || 10
|
265
312
|
w = for_text ? 'tw' : 'w'
|
266
313
|
h = for_text ? 'th' : 'h'
|
267
314
|
case @options[:watermark_position]
|
268
315
|
when 'bottom_left'
|
269
|
-
"x=#{
|
316
|
+
"x=#{margin_x}:y=H-#{h}-#{margin_y}"
|
270
317
|
when 'top_left'
|
271
|
-
"x=#{
|
318
|
+
"x=#{margin_x}:y=#{margin_y}"
|
272
319
|
when 'bottom_right'
|
273
|
-
"x=W-#{w}-#{
|
320
|
+
"x=W-#{w}-#{margin_x}:y=H-#{h}-#{margin_y}"
|
274
321
|
when 'top_right'
|
275
|
-
"x=W-#{w}-#{
|
322
|
+
"x=W-#{w}-#{margin_x}:y=#{margin_y}"
|
276
323
|
else
|
277
|
-
"x=#{
|
324
|
+
"x=#{margin_x}:y=H-#{h}-#{margin_y}"
|
278
325
|
end
|
279
326
|
end
|
280
327
|
end
|
data/lib/libis/format/version.rb
CHANGED
data/libis-format.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'deep_dive', '~> 0.3'
|
30
30
|
spec.add_runtime_dependency 'libis-mapi', '~> 0.3'
|
31
31
|
spec.add_runtime_dependency 'libis-tools', '~> 1.1'
|
32
|
-
spec.add_runtime_dependency 'mini_magick', '~>
|
32
|
+
spec.add_runtime_dependency 'mini_magick', '~> 5.0.1'
|
33
33
|
spec.add_runtime_dependency 'naturally', '~> 2.2'
|
34
34
|
spec.add_runtime_dependency 'new_rfc_2047', '~> 1.0'
|
35
35
|
spec.add_runtime_dependency 'os', '~> 1.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chromaprint
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.0.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.0.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: naturally
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,7 +352,7 @@ homepage: ''
|
|
352
352
|
licenses:
|
353
353
|
- MIT
|
354
354
|
metadata: {}
|
355
|
-
post_install_message:
|
355
|
+
post_install_message:
|
356
356
|
rdoc_options: []
|
357
357
|
require_paths:
|
358
358
|
- lib
|
@@ -367,8 +367,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
367
367
|
- !ruby/object:Gem::Version
|
368
368
|
version: '0'
|
369
369
|
requirements: []
|
370
|
-
rubygems_version: 3.5.
|
371
|
-
signing_key:
|
370
|
+
rubygems_version: 3.5.22
|
371
|
+
signing_key:
|
372
372
|
specification_version: 4
|
373
373
|
summary: LIBIS File format format services.
|
374
374
|
test_files: []
|