easyimg_utils 0.3.0 → 0.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/easyimg_utils.rb +102 -3
- metadata +26 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 963ee21d36cbeebb33c72de68a6a49d0af25f0ed1506de4d6fc15988869b56e4
|
4
|
+
data.tar.gz: 951d7659262c844841fb4ee948e80feef8a542fac1e92716dad25c91f821a545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a24e17f9fa176174c0aee4f8b235dd95e3f07967f07db7ffc2fc004800109cf0d52be8433f10c1772011d982be1adb747c28c022686d6d61570bd1e55151e5
|
7
|
+
data.tar.gz: 5aae87c99e9d38b3861af3c5e6f4935ba3e2b572afa810336be91b6966fa252912725fee42e7328b705bdb2f6adfd0048520f9c4d0e0911f872c3b1ea336ef86
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyimg_utils.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'c32'
|
6
6
|
require 'rxfhelper'
|
7
7
|
require 'rmagick'
|
8
|
+
require 'webp_ffi'
|
8
9
|
|
9
10
|
# requirements:
|
10
11
|
#
|
@@ -13,6 +14,10 @@ require 'rmagick'
|
|
13
14
|
#
|
14
15
|
# viewer:
|
15
16
|
# apt-get install feh
|
17
|
+
#
|
18
|
+
# webp-ffi dependencies
|
19
|
+
# apt-get install libjpeg-dev libpng-dev libtiff-dev libwebp-dev
|
20
|
+
#
|
16
21
|
|
17
22
|
|
18
23
|
|
@@ -46,15 +51,21 @@ class EasyImgUtils
|
|
46
51
|
* add_svg # adds an SVG transparency overlay. usage: add_svg('/tmp/image1.svg')
|
47
52
|
* add_text # e.g. add_text('some text')
|
48
53
|
* blur # e.g. blur(x: 231, y: 123, w: 85, h: 85)
|
54
|
+
* capture_screen # takes a screenshot of the desktop
|
49
55
|
* center_crop # crops from the centre of an image. Usage center_crop(width, height)
|
50
56
|
* composite # overlay a smaller image on top of an image
|
51
57
|
* contrast # changes the intensity between lighter and darker elements
|
58
|
+
* convert # convert from 1 img format to another
|
52
59
|
* crop # e.g. crop(x: 231, y: 123, w: 85, h: 85)
|
53
60
|
* fax_effect # Produces a high-contrast, two colour image
|
54
61
|
* greyscale # Reduces the image to 256 shades of grey
|
55
62
|
* info # returns the dimension of the image in a Hash object
|
56
63
|
* make_thumbnail # similar to resize but faster for sizes less than 10% of original image
|
57
64
|
* resize # set the maximum geomertry of the image for resizing e.g. resize('320x240')
|
65
|
+
* rotate
|
66
|
+
* rotate_180
|
67
|
+
* rotate_left
|
68
|
+
* rotate_right
|
58
69
|
* sketch # renders an artistic sketch, ideal with simplistic photos
|
59
70
|
* view # view the output
|
60
71
|
* vignette # Feathers the edge of an image in a circular path
|
@@ -62,9 +73,10 @@ class EasyImgUtils
|
|
62
73
|
|
63
74
|
|
64
75
|
def initialize(img_in=nil, img_out=nil, out: img_out,
|
65
|
-
working_dir: '/tmp')
|
76
|
+
working_dir: '/tmp', debug: false)
|
66
77
|
|
67
78
|
@file_in, @file_out, @working_dir = img_in, out, working_dir
|
79
|
+
@debug = debug
|
68
80
|
|
69
81
|
end
|
70
82
|
|
@@ -126,6 +138,24 @@ class EasyImgUtils
|
|
126
138
|
write img, quality
|
127
139
|
|
128
140
|
end
|
141
|
+
|
142
|
+
def brightness(quality: nil)
|
143
|
+
img = read()
|
144
|
+
img2 = imglevel(-Magick::QuantumRange * 0.25, Magick::QuantumRange * 1.25, 1.0)
|
145
|
+
write img2, quality
|
146
|
+
end
|
147
|
+
|
148
|
+
def capture_screen(quality: nil)
|
149
|
+
|
150
|
+
# defaults (silent=false, frame=false, descend=false,
|
151
|
+
# screen=false, borders=false)
|
152
|
+
|
153
|
+
img = Magick::Image.capture(true, false, false, true, true) {
|
154
|
+
self.filename = "root"
|
155
|
+
}
|
156
|
+
write img, quality
|
157
|
+
|
158
|
+
end
|
129
159
|
|
130
160
|
def center_crop(w=0, h=0, width: w, height: h, quality: nil)
|
131
161
|
|
@@ -156,6 +186,9 @@ class EasyImgUtils
|
|
156
186
|
|
157
187
|
end
|
158
188
|
|
189
|
+
alias overlay composite
|
190
|
+
alias add_img composite
|
191
|
+
|
159
192
|
# contrast level
|
160
193
|
# 1 low -> 10 high
|
161
194
|
#
|
@@ -175,6 +208,33 @@ class EasyImgUtils
|
|
175
208
|
|
176
209
|
end
|
177
210
|
|
211
|
+
def convert(quality: nil)
|
212
|
+
|
213
|
+
if File.extname(@file_in) == '.webp' then
|
214
|
+
|
215
|
+
# output_format options: pam, ppm, pgm, bmp, tiff or yuv
|
216
|
+
ext = File.extname(@file_out)[1..-1].to_sym
|
217
|
+
puts 'ext: ' + ext.inspect if @debug
|
218
|
+
|
219
|
+
if ext == :jpg then
|
220
|
+
|
221
|
+
file_out = @file_out.sub(/\.jpg$/,'.png')
|
222
|
+
WebP.decode(@file_in, file_out, output_format: :png)
|
223
|
+
img = read(file_out)
|
224
|
+
write img, quality
|
225
|
+
|
226
|
+
else
|
227
|
+
|
228
|
+
WebP.decode(@file_in, @file_out, output_format: ext)
|
229
|
+
end
|
230
|
+
|
231
|
+
else
|
232
|
+
img = read()
|
233
|
+
write img, quality
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
178
238
|
def crop(x: 0, y: 0, w: nil, h: nil, quality: nil)
|
179
239
|
|
180
240
|
return unless w
|
@@ -225,6 +285,8 @@ class EasyImgUtils
|
|
225
285
|
write img2, quality
|
226
286
|
|
227
287
|
end
|
288
|
+
|
289
|
+
alias thumbnail make_thumbnail
|
228
290
|
|
229
291
|
# defines the maximum size of an image while maintaining aspect ratio
|
230
292
|
#
|
@@ -240,6 +302,39 @@ class EasyImgUtils
|
|
240
302
|
|
241
303
|
end
|
242
304
|
|
305
|
+
def rotate(degrees)
|
306
|
+
|
307
|
+
img = read()
|
308
|
+
img2 = img.rotate(degrees.to_i)
|
309
|
+
write img2, quality
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
def rotate_180()
|
314
|
+
|
315
|
+
img = read()
|
316
|
+
img2 = img.rotate(180)
|
317
|
+
write img2, quality
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
def rotate_left()
|
322
|
+
|
323
|
+
img = read()
|
324
|
+
img2 = img.rotate(-45)
|
325
|
+
write img2, quality
|
326
|
+
|
327
|
+
end
|
328
|
+
|
329
|
+
def rotate_right()
|
330
|
+
|
331
|
+
img = read()
|
332
|
+
img2 = img.rotate(45)
|
333
|
+
write img2, quality
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
|
243
338
|
def sketch(quality: nil)
|
244
339
|
|
245
340
|
img = read()
|
@@ -256,6 +351,8 @@ class EasyImgUtils
|
|
256
351
|
write img, quality
|
257
352
|
|
258
353
|
end
|
354
|
+
|
355
|
+
alias drawing sketch
|
259
356
|
|
260
357
|
def view(show: true)
|
261
358
|
|
@@ -273,11 +370,13 @@ class EasyImgUtils
|
|
273
370
|
write img2, quality
|
274
371
|
|
275
372
|
end
|
373
|
+
|
374
|
+
alias feathered_around vignette
|
276
375
|
|
277
376
|
private
|
278
377
|
|
279
|
-
def read()
|
280
|
-
data, type = RXFHelper.read(
|
378
|
+
def read(file=@file_in)
|
379
|
+
data, type = RXFHelper.read(file)
|
281
380
|
Magick::Image.from_blob(data).first
|
282
381
|
end
|
283
382
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyimg_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
6PB/a3YCkvA1ipebq/pmmvF9VopoG5giimE7Rkw0QPUi/w6724YH6tVQj077N2mP
|
36
36
|
WOpXPMFUK6eXTvN8BbxLtUkt
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-
|
38
|
+
date: 2019-07-28 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rmagick
|
@@ -43,20 +43,20 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 4.0.0
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '4.0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 4.0.0
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '4.0'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rxfhelper
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +77,26 @@ dependencies:
|
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: 0.9.4
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webp-ffi
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0.2'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.7
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.2.7
|
80
100
|
description:
|
81
101
|
email: james@jamesrobertson.eu
|
82
102
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|