Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read HEIC image size. #140

Closed
tateisu opened this issue May 15, 2023 · 1 comment · Fixed by #145
Closed

Can't read HEIC image size. #140

tateisu opened this issue May 15, 2023 · 1 comment · Fixed by #145

Comments

@tateisu
Copy link

tateisu commented May 15, 2023

from mastodon/mastodon#23588

version: fastimage (2.2.6)

step to reproduce

$ bundler init
$ vi Gemfile
$ bundle install --path vendor/bundle
$ bundle exec ruby test.rb 20230514_113330.heic

Gemfile

source "https://rubygems.org"
gem 'fastimage'

test.rb

require "rubygems"
require 'fastimage'
ARGV.each do |a|
  p a,FastImage.size(a)
end

sample HEIC file.
20230514_113330.zip

result

"20230514_113330.heic"
nil

expected behavior

  • could read image size.
@tateisu
Copy link
Author

tateisu commented May 16, 2023

FastImage assumes metadata at the beginning of the file early in the search, but it's usualy thing ISOBMFF file have metadata at the end of file.

Box structure of this sample file (Samsung phone camera app)

00000000 <>root 579414 (4 subItems)
00000000   ftyp 16 {compatibleBrands:["mif1", "heic"], majorBrand:"heic", minorVersion:(u32)0}
00000018   mdat 576574 %00%00E%03&%01%af%b0e%8c%e4%b3%c6%97%b1%1b%e7_%e9t%cf%eaD%b5:9<D%98%9bc%1d
0008cc5e   meta 2690 (7 subItems)
0008cc6a     hdlr 26 {a:(u32)0, b:(u32)0, c:(u32)0, flags:(u32)0, handlerType:"pict", name:" ", nameNulTerminated:true, shouldBeZeroButAppleWritesHereSomeValue:(u32)0, version:(u32)0}
0008cc8c     iinf 1077 %00%00%00%00%003%00%00%00%15infe%02%00%00%01%00%01%00%00hvc1%00%00%00%00%15i
0008d0c9     pitm 6 %00%00%00%00%001
0008d0d7     iprp 553 (2 subItems)
0008d0df       ipco 280 (5 subItems)
0008d0e7         hvcC 102 %01%01`%00%00%00%b0%00%00%00%00%00]%f0%00%fc%fd%f8%f8%00%00%03%03%20%00%01%00%17@%01%0c%01
0008d155         ispe 12 %00%00%00%00%00%00%02%00%00%00%02%00
0008d169         ispe 12 %00%00%00%00%00%00%0f%a0%00%00%0b%b8
0008d17d         hvcC 102 %01%01`%00%00%00%b0%00%00%00%00%00Z%f0%00%fc%fd%f8%f8%00%00%03%03%20%00%01%00%17@%01%0c%01
0008d1eb         ispe 12 %00%00%00%00%00%00%02%00%00%00%01%80
0008d1ff       ipma 257 %00%00%00%00%00%00%002%00%01%02%81%82%00%02%02%81%82%00%03%02%81%82%00%04%02%81%82%00%05%02%81
0008d308     iloc 824 %01%00%00%00D%00%003%00%01%00%00%00%00%00%01%00%00%00%20%00%00E%07%00%02%00%00%00%00%00%01
0008d648     idat 8 %00%00%05%07%0f%a0%0b%b8
0008d658     iref 140 %00%00%00%00%00%00%00ldimg%001%000%00%01%00%02%00%03%00%04%00%05%00%06%00%07%00%08
0008d6ec   sefd 98 %00%00%01%0a%0e%00%00%00Image_UTC_Data1684031611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant