Hi,

I am probably missing something here, but let me try and explain my issue:

The following piece of code compiles and runs fine on Linux:
         [...]
             Image tmpImage(pos->getFullPath());
             try {
                 tmpImage.zoom(size);
               string target = targetDir + separator + pos->getFileName();
               cout << target << endl;
               tmpImage.write(target);
             } catch (Exception &error_) {
                 Logger::log(ERROR,error_.what());
                 tmpImage.~Image();
                 return;
             }
          [...]

It also compiles and runs fine in cygwin, when the paths of the images are
Unix style paths (/usr/dir/whatever). Now in cygwin, you can refer paths
using the windows notation (C:\cygwin\usr\dir\whatever) and it should in
theory continue to work with some tweaks in the code ... The above code
atually creates a non-empty file about the size of the actual jpeg, but
completely unreadable (corrupted?). After spending a whole day on this, I
managed to get it working by applying the following changes:
         [...]
             Image tmpImage(pos->getFullPath());
             try {
                 tmpImage.zoom(size);
               string target = targetDir + separator + pos->getFileName();
               cout << target << endl;
               tmpImage.write(target);
               // nothing, nada
               tmpImage.write(target);
               // tada, the jpeg is now on the disk
             } catch (Exception &error_) {
                 Logger::log(ERROR,error_.what());
                 tmpImage.~Image();
                 return;
             }
          [...]

I simply call the Image.write function a second time, and that seems to
work. I first thought of race conditions in the code, so I inserted a few
sleep (10) here and there, also changed and printed out the paths to make
sure they were good, added a few sync() after the first write, destroyed the
image object, but nothing did it ...

So I'm trying to understand what is going on, the fix seems to be working
for the moment, but I don't like it too much ... It looks like a buffer not
being flushed in this particular case (maybe the backslash in the path is
not well understood ?)

If anybody has any insights, I'd be glad to hear about them ..
Thanks

Marc
_______________________________________________
Magick-developers mailing list
Magick-developers@imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-developers

Reply via email to