format_parser 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c08f5e2482e524cf7b6c54eb4de371bbf1a107
4
- data.tar.gz: 3c33f9336c6ec7479b03102f8dbc4ab8610a6420
3
+ metadata.gz: 4bc81ce8d64a13fe43d93e7fe24b17ea484e64a4
4
+ data.tar.gz: 8d559f3fdd9f0a814b479ade6997a3d6bd7dd4a5
5
5
  SHA512:
6
- metadata.gz: b9892a12a6007744c70baa01200d432b40868d6f8d854b506dea7349ef84282133f49ab244a9d383b7772221d29dc950ae07c604b57247784f42aae74a03474b
7
- data.tar.gz: 643b274aa45ef8a11dde7e178d03036488767ba56f4e4680edf647ebb5098aff52c08bcecc9578c73bd6835aa235ac31358032806e0c28c5c113d8edad9734e1
6
+ metadata.gz: d555a6eb131261f3c9bb2418e1c7acf12dfb07de4d3b2af65a8135247b8900ddb8e1c60bc6c0d6985ac3c2bfdfc81c0902396e21436a4b4b7a5fd6eee7dcf4d7
7
+ data.tar.gz: c955511e375429fb93068220a1b7d70875a7e71760f14652fd191ad8d1a8b5c20ff20258cda030468acfc53cde070436b8515fe9af7e0f757dbe2c2d66722a03
data/README.md CHANGED
@@ -148,6 +148,9 @@ Therefore we adapt the following approaches:
148
148
 
149
149
  Unless specified otherwise in this section the fixture files are MIT licensed and from the FastImage and Dimensions projects.
150
150
 
151
+ ### JPEG
152
+ - `divergent_pixel_dimensions_exif.jpg` is used with permission from LiveKom GmbH
153
+
151
154
  ### AIFF
152
155
  - fixture.aiff was created by one of the project maintainers and is MIT licensed
153
156
 
@@ -1,3 +1,3 @@
1
1
  module FormatParser
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
@@ -15,6 +15,7 @@ class FormatParser::JPEGParser
15
15
  @width = nil
16
16
  @height = nil
17
17
  @orientation = nil
18
+ @intrinsics = {}
18
19
  scan
19
20
  end
20
21
 
@@ -51,7 +52,8 @@ class FormatParser::JPEGParser
51
52
  format: :jpg,
52
53
  width_px: @width,
53
54
  height_px: @height,
54
- orientation: @orientation
55
+ orientation: @orientation,
56
+ intrinsics: @intrinsics,
55
57
  )
56
58
  end
57
59
  end
@@ -90,8 +92,10 @@ class FormatParser::JPEGParser
90
92
  if scanner.scan_image_exif
91
93
  @exif_output = scanner.exif_data
92
94
  @orientation = scanner.orientation unless scanner.orientation.nil?
93
- @width = @exif_output.pixel_x_dimension || scanner.width
94
- @height = @exif_output.pixel_y_dimension || scanner.height
95
+ @intrinsics[:exif_pixel_x_dimension] = @exif_output.pixel_x_dimension
96
+ @intrinsics[:exif_pixel_y_dimension] = @exif_output.pixel_y_dimension
97
+ @width = scanner.width
98
+ @height = scanner.height
95
99
  end
96
100
  end
97
101
  end
@@ -18,18 +18,34 @@ describe FormatParser::JPEGParser do
18
18
  end
19
19
  end
20
20
 
21
- describe 'is able to parse all the JPEG exif examples from FastImage' do
21
+ it 'is able to parse JPEG examples with EXIF tags containing different orientations from FastImage' do
22
22
  Dir.glob(fixtures_dir + '/exif-orientation-testimages/jpg/*.jpg').each do |jpeg_path|
23
- it "is able to parse #{File.basename(jpeg_path)}" do
24
- parsed = subject.call(File.open(jpeg_path, 'rb'))
25
- expect(parsed).not_to be_nil
23
+ parsed = subject.call(File.open(jpeg_path, 'rb'))
24
+ expect(parsed).not_to be_nil
26
25
 
27
- expect(parsed.orientation).to be_kind_of(Symbol)
28
- expect(parsed.width_px).to be > 0
29
-
30
- expect(parsed.height_px).to be_kind_of(Integer)
31
- expect(parsed.height_px).to be > 0
32
- end
26
+ expect(parsed.orientation).to be_kind_of(Symbol)
27
+ expect(parsed.width_px).to be > 0
28
+ expect(parsed.height_px).to be > 0
33
29
  end
30
+
31
+ bottom_left_path = fixtures_dir + '/exif-orientation-testimages/jpg/bottom_left.jpg'
32
+ parsed = subject.call(File.open(bottom_left_path, 'rb'))
33
+ expect(parsed.orientation).to eq(:bottom_left)
34
+ expect(parsed.width_px).to eq(1240)
35
+ expect(parsed.height_px).to eq(1754)
36
+
37
+ top_right_path = fixtures_dir + '/exif-orientation-testimages/jpg/right_bottom.jpg'
38
+ parsed = subject.call(File.open(top_right_path, 'rb'))
39
+ expect(parsed.orientation).to eq(:right_bottom)
40
+ expect(parsed.width_px).to eq(1754)
41
+ expect(parsed.height_px).to eq(1240)
42
+ end
43
+
44
+ it 'gives true pixel dimensions priority over pixel dimensions in EXIF tags' do
45
+ jpeg_path = fixtures_dir + '/JPEG/divergent_pixel_dimensions_exif.jpg'
46
+ result = subject.call(File.open(jpeg_path, 'rb'))
47
+ expect(result.width_px).to eq(1920)
48
+ expect(result.height_px).to eq(1280)
49
+ expect(result.intrinsics).to eq(exif_pixel_x_dimension: 8214, exif_pixel_y_dimension: 5476)
34
50
  end
35
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Berman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-03-05 00:00:00.000000000 Z
12
+ date: 2018-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ks
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  version: '0'
231
231
  requirements: []
232
232
  rubyforge_project:
233
- rubygems_version: 2.6.11
233
+ rubygems_version: 2.5.2
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: A library for efficient parsing of file metadata