wvanbergen / oily_png Goto Github PK
View Code? Open in Web Editor NEWNative mixin to speed up ChunkyPNG.
Home Page: http://www.chunkypng.com
License: MIT License
Native mixin to speed up ChunkyPNG.
Home Page: http://www.chunkypng.com
License: MIT License
Hi there,
To save on space i'm using just the XCode Command Line Tools instead of the whole shebang. I'm running into this on installation:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c color.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c oily_png_ext.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c operations.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c png_decoding.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c png_encoding.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -Wall -c resampling.c
xcrun: Error: failed to exec real xcrun. (No such file or directory)
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o oily_png.bundle color.o oily_png_ext.o operations.o png_decoding.o png_encoding.o resampling.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lpthread -ldl -lobjc
clang: error: no such file or directory: 'color.o'
clang: error: no such file or directory: 'oily_png_ext.o'
clang: error: no such file or directory: 'operations.o'
clang: error: no such file or directory: 'png_decoding.o'
clang: error: no such file or directory: 'png_encoding.o'
clang: error: no such file or directory: 'resampling.o'
make: *** [oily_png.bundle] Error 1
Any idea if it's possible to do this with Command Line Tools?
Thanks.
I get a bunch of errors when trying to build and test this version against chunky_png
1.3.15. It seems the empty_bytearray
method has been removed.
In Debian and Ubuntu, the following tests are failing when executed in armhf (32bits):
1) OilyPNG::Color#compose_quick should use the background color as is when a fully transparent pixel is given as foreground color
Failure/Error: expect(compose_quick(@fully_transparent, @white)).to be(@white)
expected #<Integer:820> => 4294967295
got #<Integer:830> => 4294967295
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/color_spec.rb:24:in `block (3 levels) in <top (required)>'
2) OilyPNG::Color#compose_quick should compose pixels correctly
Failure/Error: expect(compose_quick(@non_opaque, @white)).to be(0x9fc2d6ff)
expected #<Integer:840> => 2680346367
got #<Integer:850> => 2680346367
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/color_spec.rb:28:in `block (3 levels) in <top (required)>'
3) OilyPNG::Color#compose_quick should compose colors exactly the same as ChunkyPNG
Failure/Error: expect(compose_quick(fg, bg)).to be(ChunkyPNG::Color.compose_quick(fg, bg))
expected #<Integer:860> => 2126858483
got #<Integer:870> => 2126858483
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/color_spec.rb:33:in `block (3 levels) in <top (required)>'
Debian bug as reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=999650
I tried to change the expect(value).to be(expected)
to expect(value).to eq(expected)
and the tests pass, but I am not sure if this is the right fix.
chunky_png
has 1.4.0
released
But cannot be used if this gem is used
I don't have any experience with C programming, but I am wondering if you might be able to see some performance improvements by using SIMD programming in a few places.
For instance, do you think it would benefit oily_png_compose_color
to use SIMD programming? There might be a few other places where SIMD could be implemented without too much effort. But, since I have no C experience I am likely underestimating the difficulties involved.
More information on SIMD:
I'm getting an error when trying to install oily_png on OSX:
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
$ sudo gem install oily_png
Fetching: chunky_png-1.3.0.gem (100%)
Successfully installed chunky_png-1.3.0
Fetching: oily_png-1.1.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing oily_png:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR="
compiling color.c
compiling oily_png_ext.c
oily_png_ext.c:43:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling operations.c
compiling png_decoding.c
png_decoding.c:315:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling png_encoding.c
png_encoding.c:239:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
1 warning generated.
compiling resampling.c
linking shared-object oily_png/oily_png.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [oily_png.bundle] Error 1
Note the error: clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future].
According to this Stack Overflow question, it's a problem with building with XCode 5.1+ installed. I'm not sure if this is something you can fix (I don't see that code in this project), but I wanted to make you aware of it.
Hey,
Any chance you could official release the current master to Rubygems? It includes fast rotate_left and rotate_right, which can benefit everyone.
Awesome extension, btw :).
I coded a pixel manipulation (exposure and tint) that composes multiple images. The code was working A1 on chunky_png but I needed a speed boost, so I changed the require to oily_png and now the composition fails on this error:
RangeError - integer 4321678595 too big to convert to `unsigned int':
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/color.rb:214:in `a'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/color.rb:214:in `opaque?'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/color.rb:268:in `compose_quick'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/canvas/operations.rb:59:in `block (2 levels) in compose!'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/canvas/operations.rb:58:in `each'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/canvas/operations.rb:58:in `block in compose!'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/canvas/operations.rb:57:in `each'
/Users/juggy/.rvm/gems/ruby-2.1.1@t2img/gems/chunky_png-1.3.0/lib/chunky_png/canvas/operations.rb:57:in `compose!'
Any pointers?
Ran into this problem while trying to switch to oily_png for PSD.rb. Because the width and height values were read from a file using BinData, they were not stored as a typical Fixnum, but as a BinData::Uint32be. This caused oily_png to throw the confusing error:
/Users/ryanlefevre/.rvm/gems/ruby-2.0.0-p195/gems/chunky_png-1.2.8/lib/chunky_png/canvas/png_encoding.rb:174:in `encode_png_image_pass_to_stream': The number of pixels does not match the canvas dimensions. (RuntimeError)
Simply changing the initialization to this fixed the problem:
png = ChunkyPNG::Image.new(width.to_i, height.to_i, ChunkyPNG::Color::TRANSPARENT)
Not sure if this is something you want to ensure internally, but I thought I would share in case anyone else runs into a similar problem!
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.