image_size 3.1.0 → 3.2.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
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +1 -1
- data/image_size.gemspec +2 -2
- data/lib/image_size.rb +17 -0
- data/spec/image_size_spec.rb +20 -0
- data/spec/images/emf/74x77.emf +0 -0
- data/spec/images/emf/77x77.emf +0 -0
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f086d46fca698649fed0a23adca9dc67e1fa3317d9f3c209f1fe7f07fcd2cb6b
|
4
|
+
data.tar.gz: ff8f5243aadd37691eb7dabaa7e4b0d3b6fb212aba286a10d86165dc174eabff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ff23aa12846de6eaeb9a8ae02cde4a152f891e863056cf901732ef1c6cd1a580befab1cb62037feed500906901018cf8cdb64b63dd6538c07f0b84c5e8ce80e
|
7
|
+
data.tar.gz: fe6d488afbac72d4a8c16e3d1457c9ae3acf82b87ac9bd6df34e4077f0a0166c47862eac796f71e34084bb7c1314e49f79963eba41ad73de935232b2f2c35bd1
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v3.2.0 (2022-11-03)
|
6
|
+
|
7
|
+
* Support `EMF` images [#21](https://github.com/toy/image_size/pull/21) [@opoudjis](https://github.com/opoudjis)
|
8
|
+
|
5
9
|
## v3.1.0 (2022-09-17)
|
6
10
|
|
7
11
|
* Document experimental fetching from http server [#18](https://github.com/toy/image_size/issues/18) [@toy](https://github.com/toy)
|
data/README.markdown
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# image_size
|
6
6
|
|
7
7
|
Measure image size using pure Ruby.
|
8
|
-
Formats: `apng`, `bmp`, `cur`, `gif`, `ico`, `j2c`, `jp2`, `jpeg`, `jpx`, `mng`, `pam`, `pbm`, `pcx`, `pgm`, `png`, `ppm`, `psd`, `svg`, `swf`, `tiff`, `webp`, `xbm`, `xpm`.
|
8
|
+
Formats: `apng`, `bmp`, `cur`, `emf`, `gif`, `ico`, `j2c`, `jp2`, `jpeg`, `jpx`, `mng`, `pam`, `pbm`, `pcx`, `pgm`, `png`, `ppm`, `psd`, `svg`, `swf`, `tiff`, `webp`, `xbm`, `xpm`.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
data/image_size.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'image_size'
|
5
|
-
s.version = '3.
|
5
|
+
s.version = '3.2.0'
|
6
6
|
s.summary = %q{Measure image size using pure Ruby}
|
7
|
-
s.description = %q{Measure following file dimensions: apng, bmp, cur, gif, ico, j2c, jp2, jpeg, jpx, mng, pam, pbm, pcx, pgm, png, ppm, psd, svg, swf, tiff, webp, xbm, xpm}
|
7
|
+
s.description = %q{Measure following file dimensions: apng, bmp, cur, emf, gif, ico, j2c, jp2, jpeg, jpx, mng, pam, pbm, pcx, pgm, png, ppm, psd, svg, swf, tiff, webp, xbm, xpm}
|
8
8
|
s.homepage = "https://github.com/toy/#{s.name}"
|
9
9
|
s.authors = ['Keisuke Minami', 'Ivan Kuchin']
|
10
10
|
s.license = 'Ruby'
|
data/lib/image_size.rb
CHANGED
@@ -95,6 +95,7 @@ private
|
|
95
95
|
when head[0, 4] == "\0\0\2\0" then :cur
|
96
96
|
when head[0, 12] == "\0\0\0\fjP \r\n\207\n" then detect_jpeg2000_type(ir)
|
97
97
|
when head[0, 4] == "\377O\377Q" then :j2c
|
98
|
+
when head[0, 4] == "\1\0\0\0" && head[40, 4] == ' EMF' then :emf
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
@@ -374,4 +375,20 @@ private
|
|
374
375
|
def size_of_j2c(ir)
|
375
376
|
ir.unpack(8, 8, 'NN')
|
376
377
|
end
|
378
|
+
|
379
|
+
EMF_UMAX = 256**4
|
380
|
+
EMF_SMAX = EMF_UMAX / 2
|
381
|
+
|
382
|
+
def size_of_emf(ir)
|
383
|
+
left, top, right, bottom =
|
384
|
+
if RUBY_VERSION < '1.9'
|
385
|
+
ir.unpack(24, 16, 'V*').map{ |u| u < EMF_SMAX ? u : u - EMF_UMAX }
|
386
|
+
else
|
387
|
+
ir.unpack(24, 16, 'L<*')
|
388
|
+
end
|
389
|
+
dpi = self.class.dpi
|
390
|
+
[right - left + 1, bottom - top + 1].map do |n|
|
391
|
+
(n.to_f * dpi / 2540).round
|
392
|
+
end
|
393
|
+
end
|
377
394
|
end
|
data/spec/image_size_spec.rb
CHANGED
@@ -19,6 +19,26 @@ describe ImageSize do
|
|
19
19
|
@server.finish
|
20
20
|
end
|
21
21
|
|
22
|
+
def supported_formats
|
23
|
+
ImageSize.private_instance_methods.map{ |name| name[/\Asize_of_(.*)\z/, 1] }.compact.sort
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'README' do
|
27
|
+
let(:readme){ File.read('README.markdown') }
|
28
|
+
|
29
|
+
it 'lists all supported formats' do
|
30
|
+
expect(readme[/^Formats: .*$/]).to eq("Formats: #{supported_formats.map{ |format| "`#{format}`" }.join(', ')}.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'gemspec' do
|
35
|
+
let(:gemspec){ Gem::Specification.load('image_size.gemspec') }
|
36
|
+
|
37
|
+
it 'lists all supported formats in description' do
|
38
|
+
expect(gemspec.description).to eq("Measure following file dimensions: #{supported_formats.join(', ')}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
22
42
|
Dir['spec/**/*'].each do |path|
|
23
43
|
next unless File.file?(path)
|
24
44
|
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_size
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke Minami
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -53,8 +53,9 @@ dependencies:
|
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '2.0'
|
56
|
-
description: 'Measure following file dimensions: apng, bmp, cur, gif, ico, j2c,
|
57
|
-
jpeg, jpx, mng, pam, pbm, pcx, pgm, png, ppm, psd, svg, swf, tiff, webp, xbm,
|
56
|
+
description: 'Measure following file dimensions: apng, bmp, cur, emf, gif, ico, j2c,
|
57
|
+
jp2, jpeg, jpx, mng, pam, pbm, pcx, pgm, png, ppm, psd, svg, swf, tiff, webp, xbm,
|
58
|
+
xpm'
|
58
59
|
email:
|
59
60
|
executables: []
|
60
61
|
extensions: []
|
@@ -86,6 +87,8 @@ files:
|
|
86
87
|
- spec/images/bmp/v3-bottom2top.42x50.bmp
|
87
88
|
- spec/images/bmp/v3-top2bottom.42x50.bmp
|
88
89
|
- spec/images/cur/32x256.cur
|
90
|
+
- spec/images/emf/74x77.emf
|
91
|
+
- spec/images/emf/77x77.emf
|
89
92
|
- spec/images/empty
|
90
93
|
- spec/images/gif/668x481.gif
|
91
94
|
- spec/images/ico/32x256.ico
|
@@ -127,7 +130,7 @@ licenses:
|
|
127
130
|
metadata:
|
128
131
|
bug_tracker_uri: https://github.com/toy/image_size/issues
|
129
132
|
changelog_uri: https://github.com/toy/image_size/blob/master/CHANGELOG.markdown
|
130
|
-
documentation_uri: https://www.rubydoc.info/gems/image_size/3.
|
133
|
+
documentation_uri: https://www.rubydoc.info/gems/image_size/3.2.0
|
131
134
|
source_code_uri: https://github.com/toy/image_size
|
132
135
|
post_install_message:
|
133
136
|
rdoc_options: []
|
@@ -157,6 +160,8 @@ test_files:
|
|
157
160
|
- spec/images/bmp/v3-bottom2top.42x50.bmp
|
158
161
|
- spec/images/bmp/v3-top2bottom.42x50.bmp
|
159
162
|
- spec/images/cur/32x256.cur
|
163
|
+
- spec/images/emf/74x77.emf
|
164
|
+
- spec/images/emf/77x77.emf
|
160
165
|
- spec/images/empty
|
161
166
|
- spec/images/gif/668x481.gif
|
162
167
|
- spec/images/ico/32x256.ico
|