Giter VIP home page Giter VIP logo

Comments (10)

zenspider avatar zenspider commented on August 15, 2024

I cannot believe you sent me a picture full of dicks. How unprofessional.

from image_science.

zenspider avatar zenspider commented on August 15, 2024

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.

bhenderson avatar bhenderson commented on August 15, 2024

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.

zenspider avatar zenspider commented on August 15, 2024

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.

bhenderson avatar bhenderson commented on August 15, 2024

there was a response on sourceforge. I'm not sure how to fix it though.

from image_science.

zenspider avatar zenspider commented on August 15, 2024

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.

 avatar commented on August 15, 2024

Note: raising here is dangerous as it can leak memory.
Proposed patch in #23

from image_science.

zenspider avatar zenspider commented on August 15, 2024

#23 applied.

I still don't have a good solution for the OP other than "rescue and hope for the best".

from image_science.

zenspider avatar zenspider commented on August 15, 2024

Unless someone has a suggestion for an alternative library that isn't imagemagick. :D

from image_science.

zenspider avatar zenspider commented on August 15, 2024

This should be fixed. Thanks!

from image_science.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.