banister / devil Goto Github PK
View Code? Open in Web Editor NEWruby bindings for devil cross platform image loading library
Home Page: http://openil.sourceforge.net
License: Other
ruby bindings for devil cross platform image loading library
Home Page: http://openil.sourceforge.net
License: Other
Hi!
I grabbed the latest version of your DevIL Ruby binding for win32 the other day. I'm really happy with it, overall (thanks for your work!).
I've run into a small snag which I'm wondering if you know about. I can do a rotate of any image of any arbitrary angle except when the image is non-square AND I ask it to rotate 90 or 270 degrees.
I'm running Ruby 1.9.2 from the official builds.
for example:
240x240 image rotate 45 -> works
240x320 image rotate 45 -> works
240x240 image rotate 90 -> segfault.
240x320 image rotate 90 -> works
require 'rubygems' require 'devil' def memory `ps -o vsz,rss -p #{$$}`.strip.split end p memory 10.times do 1_000.times do Devil.with_image("a.jpg") do |img| # img.thumbnail(100) # img.save("a_100.png") end end GC.start p Process.times p memory end
Just iterating over a with_image block causes the process's RSS to quickly grow. I'm assuming this is a memory leak.
I ran into the problem that when a call to load_image failed, subsequent calls (with images Devil normally loads without a problem) would also fail for no apparent reason.
The problem seems to be that load_image may push multiple errors codes onto Devil's error stack (in my case there where around seven), but the error_check function calls IL.GetError() only once and so only pops one code of the stack.
The next time error_check is run it will raise an exception even if the previous operation was successful as there are still errors remaining on the stack.
As a workaround I clear the stack manually, by simply calling IL.GetError() until IL::NO_ERROR is returned.
compile a Static DevIL library for windows so users dont need to install the .dll files
I prefer Fink over MacPorts and I have installed the libdevil1 package with fink.
The devil gem doesn't find it, though. I had to add -I/sw/include and -L/sw/lib to extconf.rb:
$CFLAGS += ' -I/opt/local/include/ -I/sw/include/'
$LDFLAGS += ' -L/opt/local/lib/ -L/sw/lib/'
Please add that to the standard extconf.rb
check test_ilut.rb. Haven't had time to look at this properly yet, but if anyone is having a difficulty with this i can get on it.
Hi,
I am having issues installing the gem on OS X (Snow Leopard). Installed libdevil from ports with
sudo port install libdevil
It pulls in a bunch of dependencies, among which libjpeg version 7.0.
Installing devil I get:
gem install devil
Building native extensions. This could take a while...
ERROR: Error installing devil:
ERROR: Failed to build gem native extension.
/Users/david/.rvm/rubies/ree-1.8.7-2009.10/bin/ruby extconf.rb
checking for main() in -lIL... yes
checking for main() in -lILU... yes
creating Makefile
make
gcc -I. -I. -I/Users/david/.rvm/rubies/ree-1.8.7-2009.10/lib/ruby/1.8/i686-darwin10.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -fno-strict-aliasing -pipe -fno-common -I/opt/local/include/ -c ruby_devil_ext.c
gcc -I. -I. -I/Users/david/.rvm/rubies/ree-1.8.7-2009.10/lib/ruby/1.8/i686-darwin10.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -fno-strict-aliasing -pipe -fno-common -I/opt/local/include/ -c ruby_il.c
gcc -I. -I. -I/Users/david/.rvm/rubies/ree-1.8.7-2009.10/lib/ruby/1.8/i686-darwin10.2.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -fno-strict-aliasing -pipe -fno-common -I/opt/local/include/ -c ruby_ilu.c
cc -dynamic -bundle -undefined suppress -flat_namespace -o devil.bundle ruby_devil_ext.o ruby_il.o ruby_ilu.o -L. -L/Users/david/.rvm/rubies/ree-1.8.7-2009.10/lib -L. -L/opt/local/lib/ -lILU -lIL -ldl -lobjc
ld: file not found: /opt/local/lib/libjpeg.62.dylib
collect2: ld returned 1 exit status
make: *** [devil.bundle] Error 1
Gem files will remain installed in /Users/david/.rvm/gems/ree-1.8.7-2009.10/gems/devil-0.1.9.1 for inspection.
Results logged to /Users/david/.rvm/gems/ree-1.8.7-2009.10/gems/devil-0.1.9.1/ext/devil/gem_make.out
Any idea what might be going on? I also tried to deactivate v7 of libjpeg and use the previous version. The gem installation halts at the same point, now complaining about a missing libjpeg version 7...
Any pointers appreciated!
Hello,
In the documentation page:
http://banisterfiend.wordpress.com/2009/10/14/the-devil-image-library-for-ruby/
You recommend copying DLLs into system32
That practice should be avoided because is not going to be reliable.
system32 requires administrative privileges to copy files inside of it. Under restricted environments, that is not possible.
Also, system32 on a 64bits OS is not actually 32bits, but has been kept for consistency. Instead, 32bits dlls should be placed in SysWOW64 (Windows on Windows emulation layer folder).
I recommend placing these DLLs in the Ruby/bin directory, or other "utility" directory that is not a sensitive as sytem32.
Thank you.
In 1.7.8 the underlying function ilClearColour expects color values as floating point factors (0.0 - 1.0), but the ruby wrapper is handing it bytes.
Setting the background color to some basic colors like black/white or a solid red or green actually works, as every color value above zero will be clamped to 1.0. Values in the 0x01-0xfe range will be treated as if 0xff was provided, hence setting wrong colors when used.
In example #120034 produces #FF00FF, orange #e6762b will set the clear color to white #FFFFFF.
I was unable to download older DevIL versions, so don't know if this also applies to earlier versions. Edit: Same applies to DevIL 1.1.1
DevIL 1.7.8 - src-IL/src/il_devil.c - Lines 251-268:
void ILAPIENTRY ilClearColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha)
{
// Clamp to 0.0f - 1.0f.
ClearRed = Red < 0.0f ? 0.0f : (Red > 1.0f ? 1.0f : Red);
ClearGreen = Green < 0.0f ? 0.0f : (Green > 1.0f ? 1.0f : Green);
ClearBlue = Blue < 0.0f ? 0.0f : (Blue > 1.0f ? 1.0f : Blue);
ClearAlpha = Alpha < 0.0f ? 0.0f : (Alpha > 1.0f ? 1.0f : Alpha);
if ((Red == Green) && (Red == Blue) && (Green == Blue)) {
ClearLum = Red < 0.0f ? 0.0f : (Red > 1.0f ? 1.0f : Red);
}
else {
ClearLum = 0.212671f * ClearRed + 0.715160f * ClearGreen + 0.072169f * ClearBlue;
ClearLum = ClearLum < 0.0f ? 0.0f : (ClearLum > 1.0f ? 1.0f : ClearLum);
}
return;
}
rdevil - /ext/devil/ruby_il.c - Lines 362-372:
static VALUE il_ClearColour(VALUE obj, VALUE rb_red, VALUE rb_green, VALUE rb_blue, VALUE rb_alpha)
{
ILubyte red = NUM2INT(rb_red);
ILubyte green = NUM2INT(rb_green);
ILubyte blue = NUM2INT(rb_blue);
ILubyte alpha = NUM2INT(rb_alpha);
ilClearColour(red, green, blue, alpha);
return Qnil;
}
Hi, I'm used brew to install the devil libraries and I'm unable to install the devil gem. Looks like it can't find -lILU, any ideas?
$ sudo gem install devil
Building native extensions. This could take a while...
ERROR: Error installing devil:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for main() in -lIL... yes
checking for main() in -lILU... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
--with-ILlib
--without-ILlib
--with-ILUlib
--without-ILUlib
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/devil-0.1.8 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/devil-0.1.8/ext/devil/gem_make.out
since low res desktops are having trouble
Hi, tried to install devil on Snow Leopard:
marten@martMBP ~/src/opengl/openglworld$ sudo port install libdevil
dlopen(/opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib, 10): no suitable image found. Did find:
/opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib: mach-o, but wrong architecture
while executing
"load /opt/local/share/macports/Tcl/pextlib1.0/Pextlib.dylib"
("package ifneeded Pextlib 1.0" script)
invoked from within
"package require Pextlib 1.0"
(file "/opt/local/bin/port" line 40)
Any ideas?
In new versions of Ruby on Win32 gem installs fine, but any references to it give the following errors:
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
cannot load such file -- C:/Ruby193/lib/ruby/gems/1.9.1/gems/devil-0.1.9.5-x86-m
ingw32/lib/devil.so (LoadError)
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/devil-0.1.9.5-x86-mingw32/lib/d
evil.rb:15:in `rescue in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/devil-0.1.9.5-x86-mingw32/lib/d
evil.rb:8:in `<top (required)>'
devil-0.1.9.5/lib/devil.rb:6:in `<top (required)>': uninitialized constant Config (NameError)
The fix is changing Config to RbConfig
Something similar to chef/ohai#454
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.