easyimg_utils 0.5.0 → 0.6.4
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 +43 -2
- metadata +36 -15
- 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: e12a8d7ad03689334172c8068730efef5acd22474b4f3b3a0d0f73994fa6f0c3
|
4
|
+
data.tar.gz: a2e24819dc0efd620fa16797286034f0cce333d1ef360eb6bb2e6a4b106ca36e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d5acd5bfef69e8cec1dc304f92e440070be9412d189fee2ce6d6c2b884593d9776b1bf04978dd572d62aea372fc0f636c6bf68c5dfd5338dcafbb9742647620
|
7
|
+
data.tar.gz: 4ea3afa5a48559a84d38e7806cf7ab27b3827ffcd1f6d2ef9cfbe0240f0d06e71987e9b2ef9316a2b510f8584ad605c67aa0512e41bd973c745d9c82ede407b1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/easyimg_utils.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
# file: easyimg_utils.rb
|
4
4
|
|
5
5
|
require 'c32'
|
6
|
-
require '
|
6
|
+
require 'x4ss'
|
7
7
|
require 'rmagick'
|
8
8
|
require 'webp_ffi'
|
9
|
+
require 'rxfhelper'
|
9
10
|
|
10
11
|
# requirements:
|
11
12
|
#
|
@@ -46,6 +47,7 @@ class EasyImgUtils
|
|
46
47
|
extend CommandHelper
|
47
48
|
include Magick
|
48
49
|
include RXFHelperModule
|
50
|
+
|
49
51
|
|
50
52
|
@commands = "
|
51
53
|
* add rectangle # usage: add_rectangle(color: 'green', x1: 12, y1: 12, x2: 24, y2: 24)
|
@@ -54,6 +56,7 @@ class EasyImgUtils
|
|
54
56
|
* animate Creates an animated gif e.g. animate('/tmp/a%d.png', '/tmp/b.gif')
|
55
57
|
* blur # e.g. blur(x: 231, y: 123, w: 85, h: 85)
|
56
58
|
* capture_screen # takes a screenshot of the desktop
|
59
|
+
* calc_resize # e.g. calc_resize '640x480' #=> 640x491
|
57
60
|
* center_crop # crops from the centre of an image. Usage center_crop(width, height)
|
58
61
|
* composite # overlay a smaller image on top of an image
|
59
62
|
* contrast # changes the intensity between lighter and darker elements
|
@@ -69,6 +72,7 @@ class EasyImgUtils
|
|
69
72
|
* rotate_left
|
70
73
|
* rotate_right
|
71
74
|
* scale # Scales an image by the given factor e.g. 0.75 is 75%. see also resize
|
75
|
+
* screencast # records a screencast and saves it as animated gif. e.g. (out: '/tmp/fun.gif').screencast
|
72
76
|
* sketch # renders an artistic sketch, ideal with simplistic photos
|
73
77
|
* view # view the output
|
74
78
|
* vignette # Feathers the edge of an image in a circular path
|
@@ -83,6 +87,20 @@ class EasyImgUtils
|
|
83
87
|
|
84
88
|
end
|
85
89
|
|
90
|
+
# e.g. calc_resize '1449x1932', '640x480' #=> 480x640
|
91
|
+
#
|
92
|
+
def self.calc_resize(s, s2)
|
93
|
+
|
94
|
+
a = s.split('x',2).map(&:to_i)
|
95
|
+
a2 = s2.split('x',2).map(&:to_i)
|
96
|
+
i = a.index a.max
|
97
|
+
|
98
|
+
factor = a2[i] / a[i].to_f
|
99
|
+
|
100
|
+
s3 = a.map {|x| (x * factor).round}.join('x')
|
101
|
+
|
102
|
+
end
|
103
|
+
|
86
104
|
def add_rectangle(a=[], quality: nil, color: 'green', stroke_width: 5,
|
87
105
|
x1: 0, y1: 0, x2: 0, y2: 0)
|
88
106
|
|
@@ -167,6 +185,12 @@ class EasyImgUtils
|
|
167
185
|
end
|
168
186
|
end
|
169
187
|
|
188
|
+
# calculates the new geometry after a resize
|
189
|
+
#
|
190
|
+
def calc_resize(geometry)
|
191
|
+
EasyImgUtils.calc_resize(info()[:geometry], geometry)
|
192
|
+
end
|
193
|
+
|
170
194
|
def capture_screen(quality: nil)
|
171
195
|
|
172
196
|
# defaults (silent=false, frame=false, descend=false,
|
@@ -380,8 +404,25 @@ class EasyImgUtils
|
|
380
404
|
end
|
381
405
|
|
382
406
|
end
|
407
|
+
|
408
|
+
# Takes a screenshot every second to create an animated gif
|
409
|
+
#
|
410
|
+
def screencast(duration: 6, scale: 1, window: true)
|
383
411
|
|
412
|
+
fileout = @file_out.sub(/\.\w+$/,'%d.png')
|
384
413
|
|
414
|
+
puts 'fileout: ' + fileout if @debug
|
415
|
+
|
416
|
+
x4ss = X4ss.new fileout, mouse: true, window: true
|
417
|
+
mode = window ? :window : :screen
|
418
|
+
sleep 2; x4ss.record duration: duration, mode: mode
|
419
|
+
x4ss.save
|
420
|
+
|
421
|
+
fileout2 = fileout.sub(/(?=%)/,'b')
|
422
|
+
EasyImgUtils.new(fileout, fileout2).scale(scale) unless scale == 1
|
423
|
+
EasyImgUtils.new(fileout2, @file_out).animate
|
424
|
+
|
425
|
+
end
|
385
426
|
|
386
427
|
def sketch(quality: nil)
|
387
428
|
|
@@ -435,7 +476,7 @@ class EasyImgUtils
|
|
435
476
|
globfilepath = file.sub('%d','*')
|
436
477
|
|
437
478
|
a = Dir[globfilepath]
|
438
|
-
|
479
|
+
puts 'a: ' + a.inspect if @debug
|
439
480
|
a.sort_by {|x| Regexp.new(regfilepath).match(x).captures[0].to_i }
|
440
481
|
|
441
482
|
else
|
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.6.4
|
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:
|
38
|
+
date: 2021-03-20 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rmagick
|
@@ -43,62 +43,82 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '4.
|
46
|
+
version: '4.2'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 4.
|
49
|
+
version: 4.2.2
|
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: '4.
|
56
|
+
version: '4.2'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 4.
|
59
|
+
version: 4.2.2
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rxfhelper
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '1.1'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 1.1.3
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '1.1'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 1.1.3
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: webp-ffi
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: '0.
|
86
|
+
version: '0.3'
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.3.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.3'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.3.1
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: x4ss
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.2.0
|
94
107
|
- - "~>"
|
95
108
|
- !ruby/object:Gem::Version
|
96
109
|
version: '0.2'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
97
114
|
- - ">="
|
98
115
|
- !ruby/object:Gem::Version
|
99
|
-
version: 0.2.
|
116
|
+
version: 0.2.0
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0.2'
|
100
120
|
description:
|
101
|
-
email:
|
121
|
+
email: digital.robertson@gmail.com
|
102
122
|
executables: []
|
103
123
|
extensions: []
|
104
124
|
extra_rdoc_files: []
|
@@ -123,7 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
143
|
- !ruby/object:Gem::Version
|
124
144
|
version: '0'
|
125
145
|
requirements: []
|
126
|
-
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.7.10
|
127
148
|
signing_key:
|
128
149
|
specification_version: 4
|
129
150
|
summary: Makes manipulating images from 1 line of code easier.
|
metadata.gz.sig
CHANGED
Binary file
|