image_science's Issues
test_class_with_image_missing_with_img_extension fails
This test fails even under Ruby 1.8.7/1.9.2 without any patches
on top of commit 1816f8c
- Failure:
test_class_with_image_missing_with_img_extension(TestImageScience) [../tes
RuntimeError expected but nothing was raised.
This failure may be dependent on the version of FreeImage used,
I'm using libfreeimage 3.10.0-4+b1 in Debian testing.
Originally discovered while working on another bug, but happens
without the patch here:
http://rubyforge.org//tracker/?func=detail&atid=5923&aid=29474&group_id=1513
Jpg compression
I need the ability to specify the jpg quality that is being saved out. Look like it is being forced to JPEG_QUALITYSUPERB. For some files JPEG_QUALITYSUPERB is perfect but for other purposes I need more compression.
Memory leak in ReOrient function
image_science leaks whenever the ReOrient function is called. In the following code snippet from lib/image_science.rb, the old bitmap is not being freed when the new, rotated bitmap is given to the variable.
switch (tagValue == NULL ? 0 : *((short *) FreeImage_GetTagValue(tagValue))) {
case 6:
bitmap = FreeImage_RotateClassic(bitmap, 270);
break;
case 3:
bitmap = FreeImage_RotateClassic(bitmap, 180);
break;
case 8:
bitmap = FreeImage_RotateClassic(bitmap, 90);
break;
default:
break;
}
Here's some ruby you can run to reproduce the leak:
require 'image_science'
image = File.read('rotated_image.jpg')
1000.times do
ImageScience.with_image_from_memory(image) { }
end
And this is the image I'm using: https://dl.dropboxusercontent.com/u/4234581/rotated_image.jpg
inline file not changed after upgrade
upgrading from 1.2.3 to 1.2.4 does not update the generated inline file. This causes the latest commit (orientation logic) to not work. This is probably a bug in rubyinline.
thoughts?
Cropping an png image modifies background and transparency
On some OS (Fedora, not on Mac OS), it seems that cropping an image modifies also its background and transparency settings. Is there any fix for that.
Thanks a lot
EXIF orientation problems
Hi - I've been having trouble with image_science's handling of EXIF orientation tags. It auto-rotates the image when it's loaded via with_image, which is fine. But if you then save that image, it writes the auto-rotated data, and includes the orientation tag from the original file. If you then open that file in a program that understands EXIF tags, it's going to add a further rotation to the autorotated data. Does that make sense? So if an image with a 90° CW EXIF tag passes through image_science, the resulting image will be rotated 180 ° when viewed in an exif-compatible program.
I've been looking at this and came to the conclusion that FreeImage's handling of exif tags meant it was more or less impossible to fix within image_science, since (AFAICT), they don't support writing exif tags on anything except TIFFs (http://switch.dl.sourceforge.net/project/freeimage/Source%20Documentation/3.15.3/FreeImage3153.pdf, page 72). I'm currently manually stripped the orientation tag out of our resulting images by shelling out to exiftool, but wondered if anyone else had run into this problem or had any suggestions.
Broken documentation link
This link appears to no longer work:
Errors compiling under 1.9.3-preview1
We are getting this error when trying to start our application with image_science under 1.9.3-preview1:
/home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb: In function 'with_image_from_memory': /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb:209: error: ISO C90 forbids mixed declarations and code /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb:222: error: ISO C90 forbids mixed declarations and code /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb: In function 'save': /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb:290: error: ISO C90 forbids mixed declarations and code /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/RubyInline-3.9.0/lib/inline.rb:590:in `build': error executing "gcc -shared -I/usr/local/include -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=implicit-function-declaration -fPIC -I /home/travis/.rvm/rubies/ruby-1.9.3-preview1/include/ruby-1.9.1 -I /home/travis/.rvm/rubies/ruby-1.9.3-preview1/include/ruby-1.9.1/x86_64-linux -I /home/travis/.rvm/rubies/ruby-1.9.3-preview1/include -L/home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib -o \"/home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/x86_64-linux/.ruby_inline/Inline_ImageScience_1c7c.so\" \"/home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/x86_64-linux/.ruby_inline/Inline_ImageScience_1c7c.c\" -L/usr/local/lib -lfreeimage -lfreeimage -lstdc++ ": pid 12834 exit 1 (CompilationError) Renamed /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/x86_64-linux/.ruby_inline/Inline_ImageScience_1c7c.c to /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/x86_64-linux/.ruby_inline/Inline_ImageScience_1c7c.c.bad from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/RubyInline-3.9.0/lib/inline.rb:828:in `inline' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb:90:in `' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bundler/gems/image_science-9b9ba4367f64/lib/image_science.rb:13:in `' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:in `require' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:68:in `block (2 levels) in require' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:in `each' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:66:in `block in require' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:in `each' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler/runtime.rb:55:in `require' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/bundler-1.0.17/lib/bundler.rb:120:in `require' from /home/travis/zerista/app/config/application.rb:34:in `' from /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/travis/zerista/app/config/environment.rb:18:in `' from /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/travis/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/travis/zerista/app/config.ru:1:in `block in ' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/rack-1.3.2/lib/rack/builder.rb:51:in `instance_eval' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/rack-1.3.2/lib/rack/builder.rb:51:in `initialize' from /home/travis/zerista/app/config.ru:1:in `new' from /home/travis/zerista/app/config.ru:1:in `' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/rack/adapter/loader.rb:36:in `eval' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/rack/adapter/loader.rb:36:in `load' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/rack/adapter/loader.rb:45:in `for' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/thin/controllers/controller.rb:169:in `load_adapter' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/thin/controllers/controller.rb:73:in `start' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/thin/runner.rb:185:in `run_command' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/lib/thin/runner.rb:151:in `run!' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/gems/thin-1.2.11/bin/thin:6:in `' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bin/thin:19:in `load' from /home/travis/.rvm/gems/ruby-1.9.3-preview1@zerista/bin/thin:19:in `'
Our workaround for now is to manually compile the failed file with only these switches (note, the differences in the -I switches are just because the come from different machines):
-c -fPIC -I/usr/local/rvm/rubies/ruby-1.9.3-preview1/include/ruby-1.9.1 -I/usr/local/rvm/rubies/ruby-1.9.3-preview1/include/ruby-1.9.1/x86_64-linux
I'm not sure if this is is a configuration difference or a platform difference, but on Mac OS X (Lion), these errors are only warnings, and image_science successfully compiles; however, on ArchLinux, Gentoo, and Windows they are errors and the compile fails. The success of the compile varies on CentOS.
ENV['INLINEDIR'] can't be relative
I was setting ENV['INLINEDIR'] to "tmp", e.g. relative to my Rails.root, the correct files would get created, e.g. I have Inline_ImageScience_cdabbf6be1583cf10d50065dbe0df70a.so
and Inline_ImageScience_cdabbf6be1583cf10d50065dbe0df70a.c
in my tmp/ruby_inline/ruby-1.9.1/
folder, however rails would still fail to boot saying it can't find tmp/.ruby_inline/ruby-1.9.1/Inline_ImageScience_cdabbf6be1583cf10d50065dbe0df70a.so
.
Changing my ENV['INLINEDIR'] to File.join Rails.root, 'tmp'
fixed my problem. I.e. using an absolute path over a relative one.
Remove relative paths?
Hi,
Line 6 in b8018dd
Can we remove this relative path here?
This interferes when trying to run tests in a clean schroot for the Debian package.
Is this gem still supported?
The http://seattlerb.rubyforge.org/ URL seems to be dead
raising error on warnings
https://f.cloud.github.com/assets/26167/962446/027b0198-04f0-11e3-9c07-3bae19ce7608.jpg
When trying to process this image, we get an error raised:
RuntimeError: FreeImage exception for type JPEG: Corrupt JPEG data: 49 extraneous bytes before marker 0xd9
if I comment out this line
https://github.com/seattlerb/image_science/blob/master/lib/image_science.rb#L176
it works.
I don't know how to link to the FreeImage source, but it looks like that message is coming from here:
Source/LibJPEG/jdmarker.c:946
WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
which looks like it should be a warning and not an error.
do you have any thoughts? I'm still trying to find documentation for FreeImage_SetOutputMessage.
[PATCH] defer raising exception until wrapped by rb_ensure
Edit: adding an additional patch to quiet a -Wformat-security warning.
It is not safe to call rb_raise() directly from FreeImageErrorHandler().
We may be deep inside FreeImage code which does not expect exceptions
and have untracked allocations which need to be freed.
Otherwise, repeatedly loading an image which triggers errors/warnings
in the following script will lead to infinite memory usage:
require 'image_science'
path = ARGV.shift or abort "Usage: #$0 BADIMAGE\n"
begin
ImageScience.with_image(path) do |img|
p img.class
end
rescue => e
p [ e.class, e.message ]
end while true
Bad image example from: #21
https://f.cloud.github.com/assets/26167/962446/027b0198-04f0-11e3-9c07-3bae19ce7608.jpg
-------------------------- 8< ------------------------------
I will not endorse github for treating repos they don't host as second class citizens:
downloadable patches here:
http://bogomips.org/image_science.git/patch/?id=3145b038258888cfb1b5cbc549ad2baa9a48b1dd
http://bogomips.org/image_science.git/patch/?id=3b0c5d6da4444f19c7a1b73ac7720d10905e0cdb
Pull request here:
The following changes since commit 5271cfe:
prepped for release [git-p4: depot-paths = "//src/image_science/dev/": change = 8704](2013-06-20 16:03:00 -0800)
are available in the git repository at:
git://bogomips.org/image_science issue-23
for you to fetch changes up to 3b0c5d6da4444f19c7a1b73ac7720d10905e0cdb:
prevent -Wformat-security warnings with rb_raise (2013-11-27 17:54:20 +0000)
Eric Wong (2):
defer raising exception until wrapped by rb_ensure
prevent -Wformat-security warnings with rb_raise
lib/image_science.rb | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
Add RubyInline as a dependency
inline is a dependency but the gem RubyInline isn't listed as a dependency in the gemfile (I had to set it up manually). Unless I'm mistaken it should be listed as a dependency.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.