easyimg_utils 0.6.3 → 0.7.1
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 +35 -9
- metadata +22 -2
- 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: d5a7070bfe90782130922f1707f7143dbd2cbb8465197ff48055650f4fa137a2
|
4
|
+
data.tar.gz: 1b909e5e43b88e300b1542b44dfdb080c3c45da1f9b10e7da5ad6b3676f72118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3270ace1416ed3cd00b4d2e7ab942fdae8c1509d20d2f60cea12c488060e42b65520c08e5476a13aa603354e4300c7c9202de9b5cf8fc455efc7274f5b59b2f3
|
7
|
+
data.tar.gz: de164b42b68ca9708a8d712ee9b28e1bbdddab87d73357d254e41c883be698274bbb2cfbf8154f36c05e0cf9c88414f39ea825b1725754c43444073d6bb54aea
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyimg_utils.rb
CHANGED
@@ -7,6 +7,7 @@ require 'x4ss'
|
|
7
7
|
require 'rmagick'
|
8
8
|
require 'webp_ffi'
|
9
9
|
require 'rxfhelper'
|
10
|
+
require 'detectfaces'
|
10
11
|
|
11
12
|
# requirements:
|
12
13
|
#
|
@@ -19,6 +20,8 @@ require 'rxfhelper'
|
|
19
20
|
# webp-ffi dependencies
|
20
21
|
# apt-get install libjpeg-dev libpng-dev libtiff-dev libwebp-dev
|
21
22
|
#
|
23
|
+
# detectfaces dependencies
|
24
|
+
# apt-get install libopencv-dev
|
22
25
|
|
23
26
|
|
24
27
|
|
@@ -56,13 +59,14 @@ class EasyImgUtils
|
|
56
59
|
* animate Creates an animated gif e.g. animate('/tmp/a%d.png', '/tmp/b.gif')
|
57
60
|
* blur # e.g. blur(x: 231, y: 123, w: 85, h: 85)
|
58
61
|
* capture_screen # takes a screenshot of the desktop
|
59
|
-
* calc_resize # e.g.
|
62
|
+
* calc_resize # e.g. calc_resize '640x480' #=> 640x491
|
60
63
|
* center_crop # crops from the centre of an image. Usage center_crop(width, height)
|
61
64
|
* composite # overlay a smaller image on top of an image
|
62
65
|
* contrast # changes the intensity between lighter and darker elements
|
63
66
|
* convert # convert from 1 img format to another
|
64
67
|
* crop # e.g. crop(x: 231, y: 123, w: 85, h: 85)
|
65
68
|
* fax_effect # Produces a high-contrast, two colour image
|
69
|
+
* faces # Returns an array of bounding boxes for detected faces
|
66
70
|
* greyscale # Reduces the image to 256 shades of grey
|
67
71
|
* info # returns the dimension of the image in a Hash object
|
68
72
|
* make_thumbnail # similar to resize but faster for sizes less than 10% of original image
|
@@ -88,15 +92,25 @@ class EasyImgUtils
|
|
88
92
|
end
|
89
93
|
|
90
94
|
# e.g. calc_resize '1449x1932', '640x480' #=> 480x640
|
95
|
+
# e.g. calc_resize '518x1024', '*518x500' #=> "518x1024"
|
96
|
+
# the asterisk denotes a guaranteed the image will be resized using x or y
|
91
97
|
#
|
92
|
-
def self.calc_resize(
|
98
|
+
def self.calc_resize(geometry, new_geometry, force: false)
|
93
99
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
xy = geometry.split('x',2)
|
101
|
+
xy2 = new_geometry.split('x',2)
|
102
|
+
|
103
|
+
# find any locked geometry which guarantees the resize on either x or y
|
104
|
+
lock = xy2.find {|x| x =~ /^\*/}
|
105
|
+
|
106
|
+
a = xy.map {|x| x[/\d+/].to_i}
|
107
|
+
a2 = xy2.map {|x| x[/\d+/].to_i}
|
108
|
+
|
109
|
+
i = lock ? a2.index(lock[1..-1].to_i) : a.index(a.max)
|
110
|
+
|
111
|
+
factor = a2[i] / a[i].to_f
|
112
|
+
|
113
|
+
s3 = a.map {|x| (x * factor).round}.join('x')
|
100
114
|
|
101
115
|
end
|
102
116
|
|
@@ -184,6 +198,12 @@ class EasyImgUtils
|
|
184
198
|
end
|
185
199
|
end
|
186
200
|
|
201
|
+
# calculates the new geometry after a resize
|
202
|
+
#
|
203
|
+
def calc_resize(geometry)
|
204
|
+
EasyImgUtils.calc_resize(info()[:geometry], geometry)
|
205
|
+
end
|
206
|
+
|
187
207
|
def capture_screen(quality: nil)
|
188
208
|
|
189
209
|
# defaults (silent=false, frame=false, descend=false,
|
@@ -288,6 +308,10 @@ class EasyImgUtils
|
|
288
308
|
|
289
309
|
end
|
290
310
|
|
311
|
+
def faces()
|
312
|
+
DetectFaces.new(@file_in).faces
|
313
|
+
end
|
314
|
+
|
291
315
|
def fax_effect(threshold: 0.55, quality: nil)
|
292
316
|
|
293
317
|
read() do |img|
|
@@ -336,8 +360,10 @@ class EasyImgUtils
|
|
336
360
|
|
337
361
|
# defines the maximum size of an image while maintaining aspect ratio
|
338
362
|
#
|
339
|
-
def resize(
|
363
|
+
def resize(raw_geometry='320x240', quality: nil)
|
340
364
|
|
365
|
+
geometry = calc_resize(raw_geometry
|
366
|
+
)
|
341
367
|
read() do |preview|
|
342
368
|
|
343
369
|
preview.change_geometry!(geometry) do |cols, rows, img|
|
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.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
KY48n99T12IOioQ4ghCO1L/UAg2taLOcZbMv4WpV1p9bXKhnrow81zeogZjjiNGS
|
36
36
|
OmTAjCfyGFPC/1eXnSV5Smv8
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-03-
|
38
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rmagick
|
@@ -117,6 +117,26 @@ dependencies:
|
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0.2'
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
name: detectfaces
|
122
|
+
requirement: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 0.1.0
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.1'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 0.1.0
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.1'
|
120
140
|
description:
|
121
141
|
email: digital.robertson@gmail.com
|
122
142
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|