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

Cannot calculate image size on file_content under JRuby #6

Closed
leifg opened this issue Jul 24, 2013 · 4 comments
Closed

Cannot calculate image size on file_content under JRuby #6

leifg opened this issue Jul 24, 2013 · 4 comments

Comments

@leifg
Copy link

leifg commented Jul 24, 2013

I tried the following with JRuby (1.7.3):

data = File.read('/path/to/img.jpg')
ImageSize.new(data)

It raises me an argument error:

ArgumentError: invalid byte sequence in UTF-8
from org/jruby/RubyRegexp.java:1520:in `=~'

This code works with MRI (1.9.3).

Additionally the code:

ImageSize.path('/path/to/img.jpg').size

works on JRuby

@leifg
Copy link
Author

leifg commented Jul 24, 2013

Almost forgot:

Here is the stacktrace:

org/jruby/RubyRegexp.java:1520:in `=~'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/image_size-1.1.2/lib/image_size.rb:81:in `detect_format'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/image_size-1.1.2/lib/image_size.rb:52:in `initialize'
(pry):16:in `evaluate_ruby'
org/jruby/RubyBinding.java:134:in `eval'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:328:in `evaluate_ruby'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:278:in `re'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:254:in `rep'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:234:in `repl'
org/jruby/RubyKernel.java:1489:in `loop'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:232:in `repl'
org/jruby/RubyKernel.java:1254:in `catch'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:231:in `repl'
org/jruby/RubyKernel.java:1254:in `catch'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_instance.rb:230:in `repl'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/pry_class.rb:170:in `start'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/cli.rb:201:in `(root)'
org/jruby/RubyProc.java:255:in `call'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/cli.rb:70:in `parse_options'
org/jruby/RubyArray.java:1617:in `each'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/lib/pry/cli.rb:70:in `parse_options'
/Users/leif/.rbenv/versions/jruby-1.7.4/lib/ruby/gems/shared/gems/pry-0.9.12.2-java/bin/pry:16:in `(root)'
org/jruby/RubyKernel.java:1073:in `load'
/Users/leif/.rbenv/versions/jruby-1.7.4/bin/pry:23:in `(root)'    

@toy
Copy link
Owner

toy commented Jul 24, 2013

Probably jruby bug:

binary_string = 'abc'.encode('ASCII-8BIT')
binary_string << 'def'.encode('utf-8')
p binary_string.encoding

But I'll try to fix it

@toy
Copy link
Owner

toy commented Jul 24, 2013

v1.1.3

@toy toy closed this as completed Jul 24, 2013
@leifg
Copy link
Author

leifg commented Jul 24, 2013

Just tested it: it is fixed.

Great! Thanks for the quick bugfix

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

No branches or pull requests

2 participants