Comments (10)
I cannot believe you sent me a picture full of dicks. How unprofessional.
from image_science.
I've looked at the code and it is doing exactly what you're saying... I've filed http://sourceforge.net/p/freeimage/support-requests/31/ as a result. Not sure at this point if I have any control on how FreeImage wires up to LibJPEG.
from image_science.
Thanks!
On Wednesday, August 14, 2013, Ryan Davis wrote:
I've looked at the code and it is doing exactly what you're saying... I've
filed http://sourceforge.net/p/freeimage/support-requests/31/ as a
result. Not sure at this point if I have any control on how FreeImage wires
up to LibJPEG.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-22670160
.
from image_science.
Since I'm just raising an exception, feel free to rescue it, look at the message and retailer if it isn't this one.
On Aug 14, 2013, at 15:40, Brian Henderson [email protected] wrote:
Thanks!
On Wednesday, August 14, 2013, Ryan Davis wrote:
I've looked at the code and it is doing exactly what you're saying... I've
filed http://sourceforge.net/p/freeimage/support-requests/31/ as a
result. Not sure at this point if I have any control on how FreeImage wires
up to LibJPEG.�\
Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-22670160
.�
Reply to this email directly or view it on GitHub.
from image_science.
there was a response on sourceforge. I'm not sure how to fix it though.
from image_science.
I've added my response to their rejection and it is awaiting moderation since I'm now anonymous (I no longer have an account because it was generating spam years ago).
Here is my response:
That design doesn't make a lick of sense and it breaks the contract described in the documentation.
Here's the code I have:
void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
rb_raise(rb_eRuntimeError,
"FreeImage exception for type %s: %s",
(fif == FIF_UNKNOWN) ? "???" : FreeImage_GetFormatFromFIF(fif),
message);
}
FreeImage_SetOutputMessage(FreeImageErrorHandler);
VALUE with_image(char * input) {
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
int flags;
fif = FreeImage_GetFileType(input, 0);
if (fif == FIF_UNKNOWN) fif = FreeImage_GetFIFFromFilename(input);
if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
FIBITMAP *bitmap;
VALUE result = Qnil;
flags = fif == FIF_JPEG ? JPEG_ACCURATE : 0;
if ((bitmap = FreeImage_Load(fif, input, flags))) {
bitmap = ReOrient(bitmap);
result = wrap_and_yield(bitmap, self, fif);
}
return result;
}
rb_raise(rb_eTypeError, "Unknown file format");
return Qnil;
}
As you describe, FreeImage_SetOutputMessage is used for BOTH warnings and errors (despite what the documentation says) but I'm supposed to check whether or not I get a valid pointer from FreeImage_Load, but that pointer isn't provided or available at the time the callback is triggered.
So, the problem might be with my code... but it is also with the documentation and the design of FreeImage. Either only errors should go to the registered error handler, or the documentation needs to be clear AND there needs to be more information passed to the error handler so it can do its job properly.
Just to save some time on the back and forth... Having the error handler set some global state is NOT an acceptable workaround. This code can be called from a web service and multiple calls into with_image can be occuring at any given time.
from image_science.
Note: raising here is dangerous as it can leak memory.
Proposed patch in #23
from image_science.
#23 applied.
I still don't have a good solution for the OP other than "rescue and hope for the best".
from image_science.
Unless someone has a suggestion for an alternative library that isn't imagemagick. :D
from image_science.
This should be fixed. Thanks!
from image_science.
Related Issues (14)
- Errors compiling under 1.9.3-preview1 HOT 7
- Add RubyInline as a dependency HOT 1
- test_class_with_image_missing_with_img_extension fails HOT 2
- Broken documentation link HOT 1
- Jpg compression HOT 2
- ENV['INLINEDIR'] can't be relative HOT 1
- EXIF orientation problems HOT 6
- inline file not changed after upgrade HOT 7
- Memory leak in ReOrient function HOT 2
- Cropping an png image modifies background and transparency HOT 6
- [PATCH] defer raising exception until wrapped by rb_ensure HOT 1
- Is this gem still supported? HOT 3
- Remove relative paths? HOT 1
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.
from image_science.