fastimage 2.2.4 → 2.2.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
  SHA256:
3
- metadata.gz: 074e776db55bfd4766292bca262afc562d4d38d07d86f56f1299a666b4dc3e30
4
- data.tar.gz: 7e079013cbd7802773119a5a6b7f25377e2878c1afbeb610c68d8a8a069ad0a1
3
+ metadata.gz: cfa3d72608b0c236038f0d4917930580df5474e5b46b61bcbb5758190e0050e3
4
+ data.tar.gz: 759948e3de376e61a038c6a710b1d15a39d0459c2c20efa7fefbf3692bcc26b7
5
5
  SHA512:
6
- metadata.gz: 4c82693c20723bc22b41e9839104097b0cb435c392e8ddd19edff93aeaa1802f3319c6ad49f1b82ba3926bd1bdcc5e04870d02401ff20e745e61d26a81473c6b
7
- data.tar.gz: 230fbfd667aab5c59ce7bc53909454d2d9134fdb3c6705173d5df264a3c8a36df2d879c959df1ab4662d5e216a554ada7ba482ba3e0872b9c000d087c91e5b29
6
+ metadata.gz: 49a8af8f7dbed9c9c2de250a67cd9ff2810c7b0a5a41d79c5069b777331573de9633163cbc3a95b7a5710e695065a6266e37a255cfeb3ed380ddd29076ce34d9
7
+ data.tar.gz: 4c9136b413828a5ef790befb5b16144fdc277979c5e28b855886888ea513aa7343900269c302feb495639cd5647f0e58dcdb1a67dd812f4d1357c42adaf1ebe5
data/lib/fastimage.rb CHANGED
@@ -61,6 +61,7 @@ require 'pathname'
61
61
  require 'zlib'
62
62
  require 'base64'
63
63
  require 'uri'
64
+ require_relative 'fastimage/version'
64
65
 
65
66
  # see http://stackoverflow.com/questions/5208851/i/41048816#41048816
66
67
  if RUBY_VERSION < "2.2"
@@ -589,6 +590,7 @@ class FastImage
589
590
  end
590
591
 
591
592
  def width_and_height
593
+ @rotation = 0
592
594
  @max_size = nil
593
595
  @primary_box = nil
594
596
  @ipma_boxes = []
@@ -599,11 +601,19 @@ class FastImage
599
601
  read_boxes!
600
602
  end
601
603
 
602
- @final_size
604
+ if [90, 270].include?(@rotation)
605
+ @final_size.reverse
606
+ else
607
+ @final_size
608
+ end
603
609
  end
604
610
 
605
611
  private
606
612
 
613
+ # Format specs: https://www.loc.gov/preservation/digital/formats/fdd/fdd000525.shtml
614
+
615
+ # If you need to inspect a heic/heif file, use
616
+ # https://gpac.github.io/mp4box.js/test/filereader.html
607
617
  def read_boxes!(max_read_bytes = nil)
608
618
  end_pos = max_read_bytes.nil? ? nil : @stream.pos + max_read_bytes
609
619
  index = 0
@@ -624,6 +634,8 @@ class FastImage
624
634
  handle_hdlr_box(box_size)
625
635
  when "iprp", "ipco"
626
636
  read_boxes!(box_size)
637
+ when "irot"
638
+ handle_irot_box
627
639
  when "ispe"
628
640
  handle_ispe_box(box_size, index)
629
641
  when "mdat"
@@ -636,6 +648,10 @@ class FastImage
636
648
  end
637
649
  end
638
650
 
651
+ def handle_irot_box
652
+ @rotation = (read_uint8! & 0x3) * 90
653
+ end
654
+
639
655
  def handle_ispe_box(box_size, index)
640
656
  throw :finish if box_size < 12
641
657
 
@@ -0,0 +1,3 @@
1
+ class FastImage
2
+ VERSION = "2.2.5"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
@@ -77,6 +77,7 @@ files:
77
77
  - MIT-LICENSE
78
78
  - README.textile
79
79
  - lib/fastimage.rb
80
+ - lib/fastimage/version.rb
80
81
  homepage: http://github.com/sdsykes/fastimage
81
82
  licenses:
82
83
  - MIT