easyimg_utils 0.6.0 → 0.6.5
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 +38 -5
- metadata +17 -16
- 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: 931f6444de27b1df65cfe7e9f4b3c296e2f826f42cdb58f5bb6dc2c5f597e284
|
|
4
|
+
data.tar.gz: 119ef63fee91fd0ac7fc8402b6be7ff362a65b567279819c739449730af5d0d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18e8ec2efe4c0c7f0c0ada668f78bc5952c90b44ae7b85d9c10f121375f5752f8ddfe74709e5fdc8ff516dddd43325c084241048cd7c36d904fdae0b613fec79
|
|
7
|
+
data.tar.gz: f4e5176eb71d1aaf6e3898ec68fd823568ea4d73bcf51cf3ce176ff57f0c71ecf9678e719f1cb422ebcd0eb47663c4a005060c82c2eee4d50ec9f976ef48abed
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/easyimg_utils.rb
CHANGED
|
@@ -47,6 +47,7 @@ class EasyImgUtils
|
|
|
47
47
|
extend CommandHelper
|
|
48
48
|
include Magick
|
|
49
49
|
include RXFHelperModule
|
|
50
|
+
|
|
50
51
|
|
|
51
52
|
@commands = "
|
|
52
53
|
* add rectangle # usage: add_rectangle(color: 'green', x1: 12, y1: 12, x2: 24, y2: 24)
|
|
@@ -55,6 +56,7 @@ class EasyImgUtils
|
|
|
55
56
|
* animate Creates an animated gif e.g. animate('/tmp/a%d.png', '/tmp/b.gif')
|
|
56
57
|
* blur # e.g. blur(x: 231, y: 123, w: 85, h: 85)
|
|
57
58
|
* capture_screen # takes a screenshot of the desktop
|
|
59
|
+
* calc_resize # e.g. calc_resize '640x480' #=> 640x491
|
|
58
60
|
* center_crop # crops from the centre of an image. Usage center_crop(width, height)
|
|
59
61
|
* composite # overlay a smaller image on top of an image
|
|
60
62
|
* contrast # changes the intensity between lighter and darker elements
|
|
@@ -85,6 +87,29 @@ class EasyImgUtils
|
|
|
85
87
|
|
|
86
88
|
end
|
|
87
89
|
|
|
90
|
+
# e.g. calc_resize '1449x1932', '640x480' #=> 480x640
|
|
91
|
+
# e.g. calc_resize '518x1024', '*518x500' #=> "518x1024"
|
|
92
|
+
# the asterisk denotes a guaranteed the image will be resized using x or y
|
|
93
|
+
#
|
|
94
|
+
def self.calc_resize(geometry, new_geometry, force: false)
|
|
95
|
+
|
|
96
|
+
xy = geometry.split('x',2)
|
|
97
|
+
xy2 = new_geometry.split('x',2)
|
|
98
|
+
|
|
99
|
+
# find any locked geometry which guarantees the resize on either x or y
|
|
100
|
+
lock = xy2.find {|x| x =~ /^\*/}
|
|
101
|
+
|
|
102
|
+
a = xy.map {|x| x[/\d+/].to_i}
|
|
103
|
+
a2 = xy2.map {|x| x[/\d+/].to_i}
|
|
104
|
+
|
|
105
|
+
i = lock ? a2.index(lock[1..-1].to_i) : a.index(a.max)
|
|
106
|
+
|
|
107
|
+
factor = a2[i] / a[i].to_f
|
|
108
|
+
|
|
109
|
+
s3 = a.map {|x| (x * factor).round}.join('x')
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
|
|
88
113
|
def add_rectangle(a=[], quality: nil, color: 'green', stroke_width: 5,
|
|
89
114
|
x1: 0, y1: 0, x2: 0, y2: 0)
|
|
90
115
|
|
|
@@ -169,6 +194,12 @@ class EasyImgUtils
|
|
|
169
194
|
end
|
|
170
195
|
end
|
|
171
196
|
|
|
197
|
+
# calculates the new geometry after a resize
|
|
198
|
+
#
|
|
199
|
+
def calc_resize(geometry)
|
|
200
|
+
EasyImgUtils.calc_resize(info()[:geometry], geometry)
|
|
201
|
+
end
|
|
202
|
+
|
|
172
203
|
def capture_screen(quality: nil)
|
|
173
204
|
|
|
174
205
|
# defaults (silent=false, frame=false, descend=false,
|
|
@@ -383,20 +414,22 @@ class EasyImgUtils
|
|
|
383
414
|
|
|
384
415
|
end
|
|
385
416
|
|
|
386
|
-
#
|
|
387
|
-
# every second for a duration of 6 seconds.
|
|
417
|
+
# Takes a screenshot every second to create an animated gif
|
|
388
418
|
#
|
|
389
|
-
def screencast()
|
|
419
|
+
def screencast(duration: 6, scale: 1, window: true)
|
|
390
420
|
|
|
391
421
|
fileout = @file_out.sub(/\.\w+$/,'%d.png')
|
|
392
422
|
|
|
393
423
|
puts 'fileout: ' + fileout if @debug
|
|
394
424
|
|
|
395
425
|
x4ss = X4ss.new fileout, mouse: true, window: true
|
|
396
|
-
|
|
426
|
+
mode = window ? :window : :screen
|
|
427
|
+
sleep 2; x4ss.record duration: duration, mode: mode
|
|
397
428
|
x4ss.save
|
|
398
429
|
|
|
399
|
-
|
|
430
|
+
fileout2 = fileout.sub(/(?=%)/,'b')
|
|
431
|
+
EasyImgUtils.new(fileout, fileout2).scale(scale) unless scale == 1
|
|
432
|
+
EasyImgUtils.new(fileout2, @file_out).animate
|
|
400
433
|
|
|
401
434
|
end
|
|
402
435
|
|
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.6.
|
|
4
|
+
version: 0.6.5
|
|
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-22 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rmagick
|
|
@@ -43,60 +43,60 @@ 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
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0.
|
|
96
|
+
version: '0.3'
|
|
97
97
|
- - ">="
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: 0.
|
|
99
|
+
version: 0.3.1
|
|
100
100
|
- !ruby/object:Gem::Dependency
|
|
101
101
|
name: x4ss
|
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -118,7 +118,7 @@ dependencies:
|
|
|
118
118
|
- !ruby/object:Gem::Version
|
|
119
119
|
version: '0.2'
|
|
120
120
|
description:
|
|
121
|
-
email:
|
|
121
|
+
email: digital.robertson@gmail.com
|
|
122
122
|
executables: []
|
|
123
123
|
extensions: []
|
|
124
124
|
extra_rdoc_files: []
|
|
@@ -143,7 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
144
|
version: '0'
|
|
145
145
|
requirements: []
|
|
146
|
-
|
|
146
|
+
rubyforge_project:
|
|
147
|
+
rubygems_version: 2.7.10
|
|
147
148
|
signing_key:
|
|
148
149
|
specification_version: 4
|
|
149
150
|
summary: Makes manipulating images from 1 line of code easier.
|
metadata.gz.sig
CHANGED
|
Binary file
|