image.read() throws exception and fails. But works when creating constructor?
Posted: 2016-11-17T08:05:26-07:00
Hello,
I am using version:
Version: ImageMagick 7.0.3-5 Q16 x64 2016-11-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Windows 10 64bit.
I also installed the headers for Magic++, MagickCore, and MagickWand.
I am usinig QT Creator as an IDE. I can link and compile the Magick++ library and headers.
My Code:
This does not work. I get the following exception in the command prompt for the program:
ALSO, I can use .tiff images. If I move the action of reading the .tiff image into the Constructor it works with no problems.
like so:
So, is it that the 'catch' is returning the exception and preventing the write function from working?
Also, as this may be important, I get a ton of C4251 warnings when building the program. Probably over 50 or so:
I also get this exception error:
They all seem to be ' Needs to have dll-interface to be used by clients of class 'Magick::Exception'. So maybe I do not have something set up correctly here.
Any help will be much appreciated as I am obviously new to this.
THank You!
I am using version:
Version: ImageMagick 7.0.3-5 Q16 x64 2016-11-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Windows 10 64bit.
I also installed the headers for Magic++, MagickCore, and MagickWand.
I am usinig QT Creator as an IDE. I can link and compile the Magick++ library and headers.
My Code:
Code: Select all
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
cout << *argv << endl;
InitializeMagick(*argv);
// Construct the image object. Seperating image construction from the
// the read operation ensures that a failure to read the image file
// doesn't render the image object useless.
Image image;
try {
// Read a file into image object
image.read( "target.tif" );
// Write the image to a file
image.write( "x6.jpg" );
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}
HOWEVER. If I switch the .read image to JPEG or some other format it works. IT only fails with TIFF.Caught exception: magickTest.exe: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/905
Press <RETURN> to close this window...
ALSO, I can use .tiff images. If I move the action of reading the .tiff image into the Constructor it works with no problems.
like so:
Code: Select all
Image image("target.tif");
try {
// Write the image to a file
image.write( "x8.gif" );
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
Also, as this may be important, I get a ton of C4251 warnings when building the program. Probably over 50 or so:
]C:\Program Files\ImageMagick-7.0.3-Q16-HDRI\include\Magick++\Drawable.h:2928: warning: C4251: 'Magick::PathLinetoRel::_coordinates': class 'std::vector<Magick::Coordinate,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'Magick::PathLinetoRel'
with
[
_Ty=Magick::Coordinate
C:\Program Files\ImageMagick-7.0.3-Q16-HDRI\include\Magick++\Exception.h:23: warning: C4275: non dll-interface class 'std::exception' used as base for dll-interface class 'Magick::Exception'
C:\Program Files\ImageMagick-7.0.3-Q16-HDRI\include\Magick++\Exception.h:56: warning: C4251: 'Magick::Exception::_what': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'Magick::Exception'
I also get this exception error:
warning: Exception at 0x7ffbb5c47788, code: 0xe06d7363: C++ exception, flags=0x1 (execution cannot be continued) (first chance)
They all seem to be ' Needs to have dll-interface to be used by clients of class 'Magick::Exception'. So maybe I do not have something set up correctly here.
Any help will be much appreciated as I am obviously new to this.
THank You!