tario / imageruby

flexible and easy to use ruby gem for image processing
http://tario.github.com/imageruby/doc/
GNU General Public License v3.0
16 stars 1 forks source link

Fix for Ruby 1.9 #1

Closed amadanmath closed 13 years ago

amadanmath commented 13 years ago

Ruby 1.9 has a different treatment of "character" data type.

In 1.8.7, it's an integer. 1.9.2 treats it as one-char string. Thus, for 1.9.2 to work, it is necessary to insert the conversion functions ord and chr at appropriate places. 1.8.7 will treat ord on integers as no-op. chr is always invoked on integers, as is correct. This will make a slight performance hit, as an additional function call is performed for each pixel access.

By the way, I love the library, otherwise. :) Keep it up!

tario commented 13 years ago

Compatibility with Ruby1.9 will be one of the big milestone for the next ImageRuby release (0.3.0)

But, eventually, the performance issues will be solved using C, Metaprogramming, Ruby2C, that will be the interesting things in this project. Now, the workarounds for performance are the C extensions (imageruby-c, imageruby-bmp-c and imageruby-devil gems)

Thanks! I will take into account your tip about ruby 1.9 and characters

2011/5/18 amadanmath < reply@reply.github.com>

Ruby 1.9 has a different treatment of "character" data type.

In 1.8.7, it's an integer. 1.9.2 treats it as one-char string. Thus, for 1.9.2 to work, it is necessary to insert the conversion functions ord and chr at appropriate places. 1.8.7 will treat ord on integers as no-op. chr is always invoked on integers, as is correct. This will make a slight performance hit, as an additional function call is performed for each pixel access.

Reply to this email directly or view it on GitHub: https://github.com/tario/imageruby/pull/1

tario commented 13 years ago

Jojojo, it's a pull request, seems very good I will test that and the i will integrate

Thanks!

2011/5/18 amadanmath < reply@reply.github.com>

Ruby 1.9 has a different treatment of "character" data type.

In 1.8.7, it's an integer. 1.9.2 treats it as one-char string. Thus, for 1.9.2 to work, it is necessary to insert the conversion functions ord and chr at appropriate places. 1.8.7 will treat ord on integers as no-op. chr is always invoked on integers, as is correct. This will make a slight performance hit, as an additional function call is performed for each pixel access.

Reply to this email directly or view it on GitHub: https://github.com/tario/imageruby/pull/1

tario commented 13 years ago

I have merge your change because it pass the spec with ruby 1.8, but does not pass the spec for ruby 1.9

Do you ran the spec in ruby 1.9 with and without your change ?

2011/5/18 Dario darios3@gmail.com

Jojojo, it's a pull request, seems very good I will test that and the i will integrate

Thanks!

2011/5/18 amadanmath < reply@reply.github.com>

Ruby 1.9 has a different treatment of "character" data type.

In 1.8.7, it's an integer. 1.9.2 treats it as one-char string. Thus, for 1.9.2 to work, it is necessary to insert the conversion functions ord and chr at appropriate places. 1.8.7 will treat ord on integers as no-op. chr is always invoked on integers, as is correct. This will make a slight performance hit, as an additional function call is performed for each pixel access.

Reply to this email directly or view it on GitHub: https://github.com/tario/imageruby/pull/1

tario commented 13 years ago

Dont worry, I have fixed the other issue

2011/5/18 Dario darios3@gmail.com

I have merge your change because it pass the spec with ruby 1.8, but does not pass the spec for ruby 1.9

Do you ran the spec in ruby 1.9 with and without your change ?

2011/5/18 Dario darios3@gmail.com

Jojojo, it's a pull request, seems very good I will test that and the i will integrate

Thanks!

2011/5/18 amadanmath < reply@reply.github.com>

Ruby 1.9 has a different treatment of "character" data type.

In 1.8.7, it's an integer. 1.9.2 treats it as one-char string. Thus, for 1.9.2 to work, it is necessary to insert the conversion functions ord and chr at appropriate places. 1.8.7 will treat ord on integers as no-op. chr is always invoked on integers, as is correct. This will make a slight performance hit, as an additional function call is performed for each pixel access.

Reply to this email directly or view it on GitHub: https://github.com/tario/imageruby/pull/1

amadanmath commented 13 years ago

Sorry, didn't run spec, just patched enough to be usable - some functions were still returning different results (like Color's to_s, I think), but nothing that broke my code, and I was in a hurry - I have homework in computer vision, and needed to read some BMPs fast :)

tario commented 13 years ago

Don't worry about that, I have fixed the issues in order to pass all spec (for ruby1.8 and ruby1.9) for the version released yesterday (0.2.1)

If you want to read BMPs fast, I suggest you install imageruby-bmp-c gem (C implementation of the BMP decoder and encoder) , and for other formats you need imageruby-devil gem

2011/5/19 amadanmath < reply@reply.github.com>

Sorry, didn't run spec, just patched enough to be usable - some functions were still returning different results (like Color's to_s, I think), but nothing that broke my code, and I was in a hurry - I have homework in computer vision, and needed to read some BMPs fast :)

Reply to this email directly or view it on GitHub: https://github.com/tario/imageruby/pull/1#issuecomment-1201689

amadanmath commented 13 years ago

Heh. I meant fast as "today", not fast as "in a microsecond". Anyway, thanks for a nice gem.