Ping image out Magick::WarningCoder

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
mlm

Ping image out Magick::WarningCoder

Post by mlm »

I use magick c + + development php extension, to deal with the realization of tiff.

Code: Select all

try {
    Magick::Image image; 
    try {
      image.read("001.TIF");
    }
    catch( Magick::WarningCoder &warning )
    {
      cerr << “Coder Warning: “ << warning.what() << endl;
    }
    catch( Magick::Warning &warning )
    {
      cerr << “Warning: “ << warning.what() << endl;
    }
    catch( Magick::ErrorFileOpen &error ) 
    { 
      cerr << “Error: “ << error.what() << endl;
      continue; // Try next image.
    }
    try {
      image.rotate(90);
      image.write(“outfile”);
    }
    catch ( MagickExeption & error)
    {
       cerr << “Caught Magick++ exception: “ << error.what() << endl;
    }
  }
  catch( std::exception &error ) 
  { 
     err << “Caught C++ STD exception: “ << error.what() << endl;
  } 
  catch( ... ) 
  { 
  }
Output error:
terminate called after throwing an instance of 'Magick::WarningCoder' what(): ImageMagick: 001.TIF: Line length mismatch at line 0 of strip 0 (got 4410, expected 2704). `Fax4Decode'

System: suse10 sp1
Imagemagick:ImageMagick-6.4.4
libtiff:tiff-3.8.2
php:php 5.1.2
gcc:gcc-4.1.2_20070115-0.11

About 'Magick::WarningCoder' Description Warnings issued by some coders.
Please help me, Thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Ping image out Magick::WarningCoder

Post by magick »

We tried this program with ImageMagick 6.4.5-3 and it behaved as expected. Does it work for you? If not, post a URL to your image so we can download and reproduce the problem.

Code: Select all

#include <Magick++.h>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

using namespace Magick;

int main( int /*argc*/, char ** argv)
{

  Magick::Image image;
  try {
    // Construct an image instance first so that we don't have to worry
    // about object construction failure due to a minor warning exception
    // being thrown.
    Magick::Image image; 
    try {
      // Try reading image file
      image.read("001.tif");
    }
    catch( Magick::WarningCoder &warning )
    {
      // Process coder warning while loading file (e.g. TIFF warning)
      // Maybe the user will be interested in these warnings (or not).
      // If a warning is produced while loading an image, the image
      // can normally still be used (but not if the warning was about
      // something important!)
      cerr << "Coder Warning: " << warning.what() << endl;
    }
    catch( Magick::Warning &warning )
    {
      // Handle any other Magick++ warning.
      cerr << "Warning: " << warning.what() << endl;
    }
    catch( Magick::ErrorBlob &error ) 
    { 
      // Process Magick++ file open error
      cerr << "Error: " << error.what() << endl;
    }
    try {
      image.rotate(90);
      image.write("outfile");
    }
    catch ( Magick::Exception & error)
    {
       // Handle problem while rotating or writing outfile.
       cerr << "Caught Magick++ exception: " << error.what() << endl;
    }
  }
  catch( std::exception &error ) 
  { 
     // Process any other exceptions derived from standard C++ exception
     cerr << "Caught C++ STD exception: " << error.what() << endl;
  } 
  catch( ... ) 
  { 
    // Process *any* exception (last-ditch effort). There is not a lot
    // you can do here other to retry the operation that failed, or exit
    // the program. 
  }
  cout << "bye bye" << endl;
}
mlm

Re: Ping image out Magick::WarningCoder

Post by mlm »

Thank you reply. I now try.
Post Reply