Imagemagick коды ошибок

Success the command or algorithm completed successfully without complaint 0 0 0 Resource Limit a program resource is exhausted (e.g. not enough memory) 300 400 700 Type A font is unavailable; a substitution may have occurred 305 405 705 Option a command-line option was malformed 310 410 710 Delegate an ImageMagick delegate failed to complete 315 415 715 Missing Delegate the image type can not be read or written because the appropriate Delegate is missing 320 420 720 Corrupt Image the image file may be corrupt 325 425 725 FileOpen the image file could not be opened for reading or writing 330 430 730 Blob a binary large object could not be allocated, read, or written 335 435 735 Stream there was a problem reading or writing from a stream 340 440 740 Cache pixels could not be read or written to the pixel cache 345 445 745 Coder there was a problem with an image coder 350 450 750 Module there was a problem with an image module 355 455 755 Draw a drawing operation failed 360 460 760 Image the operation could not complete due to an incompatible image 365 465 765 Wand there was a problem specific to the MagickWand API 370 470 770 Random there is a problem generating a true or pseudo-random number 375 475 775 XServer an X resource is unavailable 380 480 780 Monitor there was a problem activating the progress monitor 385 485 785 Registry there was a problem getting or setting the registry 390 490 790 Configure there was a problem getting a configuration file 395 495 795 Policy a policy denies access to a delegate, coder, filter, path, or resource. 399 499 799

AcquireExceptionInfo

AcquireExceptionInfo() allocates the ExceptionInfo structure.

The format of the AcquireExceptionInfo method is:

ExceptionInfo *AcquireExceptionInfo(void)

ClearMagickException

ClearMagickException() clears any exception that may not have been caught yet.

The format of the ClearMagickException method is:

ClearMagickException(ExceptionInfo *exception)

A description of each parameter follows:

exception
the exception info.

CatchException

CatchException() returns if no exceptions is found otherwise it reports the exception as a warning, error, or fatal depending on the severity.

The format of the CatchException method is:

CatchException(ExceptionInfo *exception)

A description of each parameter follows:

exception
the exception info.

CloneExceptionInfo

CloneExceptionInfo() clones the ExceptionInfo structure.

The format of the CloneExceptionInfo method is:

ExceptionInfo *CloneException(ExceptionInfo *exception)

A description of each parameter follows:

exception
the exception info.

DestroyExceptionInfo

DestroyExceptionInfo() deallocates memory associated with an exception.

The format of the DestroyExceptionInfo method is:

ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)

A description of each parameter follows:

exception
the exception info.

GetExceptionMessage

GetExceptionMessage() returns the error message defined by the specified error code.

The format of the GetExceptionMessage method is:

char *GetExceptionMessage(const int error)

A description of each parameter follows:

error
the error code.

GetLocaleExceptionMessage

GetLocaleExceptionMessage() converts a enumerated exception severity and tag to a message in the current locale.

The format of the GetLocaleExceptionMessage method is:

const char *GetLocaleExceptionMessage(const ExceptionType severity,
  const char *tag)

A description of each parameter follows:

severity
the severity of the exception.
tag
the message tag.

InheritException

InheritException() inherits an exception from a related exception.

The format of the InheritException method is:

InheritException(ExceptionInfo *exception,const ExceptionInfo *relative)

A description of each parameter follows:

exception
the exception info.
relative
the related exception info.

InitializeExceptionInfo

InitializeExceptionInfo() initializes an exception to default values.

The format of the InitializeExceptionInfo method is:

InitializeExceptionInfo(ExceptionInfo *exception)

A description of each parameter follows:

exception
the exception info.

MagickError

MagickError() calls the exception handler methods with an error reason.

The format of the MagickError method is:

void MagickError(const ExceptionType error,const char *reason,
  const char *description)

A description of each parameter follows:

exception
Specifies the numeric error category.
reason
Specifies the reason to display before terminating the program.
description
Specifies any description to the reason.

MagickFatalError

MagickFatalError() calls the fatal exception handler methods with an error reason.

The format of the MagickError method is:

void MagickFatalError(const ExceptionType error,const char *reason,
  const char *description)

A description of each parameter follows:

exception
Specifies the numeric error category.
reason
Specifies the reason to display before terminating the program.
description
Specifies any description to the reason.

MagickWarning

MagickWarning() calls the warning handler methods with a warning reason.

The format of the MagickWarning method is:

void MagickWarning(const ExceptionType warning,const char *reason,
  const char *description)

A description of each parameter follows:

warning
the warning severity.
reason
Define the reason for the warning.
description
Describe the warning.

SetErrorHandler

SetErrorHandler() sets the exception handler to the specified method and returns the previous exception handler.

The format of the SetErrorHandler method is:

ErrorHandler SetErrorHandler(ErrorHandler handler)

A description of each parameter follows:

handler
the method to handle errors.

SetFatalErrorHandler

SetFatalErrorHandler() sets the fatal exception handler to the specified method and returns the previous fatal exception handler.

The format of the SetErrorHandler method is:

ErrorHandler SetErrorHandler(ErrorHandler handler)

A description of each parameter follows:

handler
the method to handle errors.

SetWarningHandler

SetWarningHandler() sets the warning handler to the specified method and returns the previous warning handler.

The format of the SetWarningHandler method is:

ErrorHandler SetWarningHandler(ErrorHandler handler)

A description of each parameter follows:

handler
the method to handle warnings.

ThrowException

ThrowException() throws an exception with the specified severity code, reason, and optional description.

The format of the ThrowException method is:

MagickBooleanType ThrowException(ExceptionInfo *exception,
  const ExceptionType severity,const char *reason,
  const char *description)

A description of each parameter follows:

exception
the exception info.
severity
the severity of the exception.
reason
the reason for the exception.
description
the exception description.

Magick::Exception Classes

Exception represents the base class of objects thrown when
Magick++reports an error. Magick++ throws C++ exceptions synchronous
with the operation where the error occurred. This allows errors to be
trapped within the enclosing code (perhaps the code to process a
single image) while allowing the code to be written with a simple
coding style.

A try/catch block should be placed around any sequence of
operations which can be considered an important body of work. For
example, if your program processes lists of images and some of these
images may be defective, by placing the try/catch block around the
entire sequence of code that processes one image (including
instantiating the image object), you can minimize the overhead of
error checking while ensuring that all objects created to deal with
that object are safely destroyed (C++ exceptions unroll the stack
until the enclosing try block, destroying any created objects).

The pseudo code for the main loop of your program may look like:

using namespace std;
for infile in list
{
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(infile);
}
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::ErrorFileOpen &error )
{
// Process Magick++ file open error
cerr << «Error: » << error.what() << endl;
continue; // Try next image.
}
try {
image.rotate(90);
image.write(«outfile»);
}
catch ( MagickExeption & 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 desired location and number of try/catch blocks in your program
depends how sophisticated its error handling must be. Very simple
programs may use just one try/catch block.

The Exception class is derived from the C++ standard
exception class. This means that it contains a C++ string containing
additional information about the error (e.g to display to the user).
Obtain access to this string via the what() method.  For
example:

catch( Exception & error_ ) 
    { 
      cout << "Caught exception: " << error_.what() << endl; 
    }

The classes Warning and Error derive from the
Exception class. Exceptions derived from Warning are
thrown to represent non-fatal errors which may effect the
completeness or quality of the result (e.g. one image provided as an
argument to montage is defective). In most cases, a Warning
exception may be ignored by catching it immediately, processing it
(e.g. printing a diagnostic) and continuing on. Exceptions derived
from Error are thrown to represent fatal errors that can not
produce a valid result (e.g. attempting to read a file which does not
exist).

The specific derived exception classes
are shown in the following tables:

Warning Sub-Classes

    Warning

    Warning Description

    WarningUndefined

    Unspecified warning type.

    WarningBlob

    NOT
    CURRENTLY USED

    WarningCache

    NOT
    CURRENTLY USED

    WarningCoder

    Warnings issued by some coders.

    WarningConfigure

    NOT
    CURRENTLY USED

    WarningCorruptImage

    Warning issued when an image is determined to be
    corrupt.

    WarningDelegate

    Warnings reported by the delegate (interface to
    external programs) subsystem.

    WarningDraw

    Warnings reported by the rendering subsystem.

    WarningFileOpen

    Warning reported when The image file could not be
    opened (permission problem, wrong file type, or does not exist).

    WarningImage

    NOT CURRENTLY USED

    WarningMissingDelegate

    NOT CURRENTLY USED

    WarningModule

    NOT CURRENTLY USED

    WarningMonitor

    NOT CURRENTLY USED

    WarningOption

    Warning reported when an option is malformed or
    out of range.

    WarningRegistry

    NOT CURRENTLY USED

    WarningResourceLimit

    Warning reported when a program resource is
    exhausted (e.g. not enough memory).

    WarningStream

    NOT CURRENTLY USED

    WarningType

    NOT CURRENTLY USED

    WarningXServer

    Warnings reported by the X11 subsystem.

Error Sub-Classes

    Error

    Error Description

    ErrorUndefined

    Unspecified error type.

    ErrorBlob

    Error reported by BLOB I/O subsystem.

    ErrorCache

    Error reported by the pixel cache subsystem.

    ErrorCoder

    Error reported by coders (image format support).

    ErrorConfigure

    Errors reported while loading configuration files.

    ErrorCorruptImage

    Error reported when the image file is corrupt.

    ErrorDelegate

    Errors reported by the delegate (interface to
    external programs) subsystem.

    ErrorDraw

    Error reported while drawing on image.

    ErrorFileOpen

    Error reported when the image file can not be
    opened.

    ErrorImage

    Errors reported while drawing.

    ErrorMissingDelegate

    Error reported when an add-on library or program
    is necessary in order to support the requested operation.

    ErrorModule

    Errors reported by the module loader subsystem.

    ErrorMonitor

    NOT CURRENTLY USED

    ErrorOption

    Error reported when an option is malformed or out
    of range.

    ErrorRegistry

    Errors reported by the image/BLOB registry
    subsystem.

    ErrorResourceLimit

    Error reported when a program resource is
    exhausted (e.g. not enough memory).

    ErrorStream

    Errors reported by the pixel stream subsystem.

    ErrorType

    Errors reported by the type (font) rendering
    subsystem.

    ErrorXServer

    Errors reported by the X11 subsystem.

—— Also opened this Bug for ImageMagick 6 — ImageMagick/ImageMagick6#106 ——

Description

Commands called without Arguments return exit code 1.
As no Error occured they should return exit code 0 as it was for years.

It seems this happened before and was corrected: http://webcache.googleusercontent.com/search?q=cache:bCKmxBhvPI8J:www.imagemagick.org/discourse-server/viewtopic.php%3Ft%3D26300+&cd=3&hl=de&ct=clnk&gl=at&client=firefox-b-d (Google Cache as old Board Links currently not working …)

But later it was changed again it seems?
Return Code Behaviour should be consistent as it’s breaking things when changed … just happened with our CMS which denied working with Images when ImageMagick was updated by «dnf update» (Centos/RHEL) …

Steps to Reproduce

Older Version:

# /usr/bin/convert -version; /usr/bin/convert >/dev/null; echo $?
Version: ImageMagick 6.7.8-10 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP    

0

Newer Version:

# /usr/bin/convert -version; /usr/bin/convert >/dev/null; echo $?
Version: ImageMagick 6.9.10-68 Q16 x86_64 2020-04-01 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(3.1) 
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jpeg lcms ltdl lzma openexr pangocairo png ps rsvg tiff wmf x xml zlib

1

Even more Newer Version:

/usr/local/bin/convert -version; /usr/local/bin/convert >/dev/null; echo $?
Version: ImageMagick 7.0.10-33 Q16 x86_64 2020-10-04 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5) 
Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw tiff webp wmf x xml zlib

1

System Configuration

  • ImageMagick version: > 6.7.8-10
  • Environment (Operating system, version and so on): Centos 7 & 8

I am executing ImageMagick command using PHP exec function, it returns an error code 4 which probably mean The system cannot open the file when however I run same command in Windows terminal it works fine. I am using this below command to resize the image:

In terminal(working fine)

convert -resize 150^% ad.png res_ad.png

In PHP (returning error code 4)

exec(escapeshellcmd("convert -resize 150% $file_name.png res_$file_name.png"), $output2, $return2)

PS: I have checked and path of the image is correct.

asked May 29, 2018 at 11:09

D555's user avatar

4

I have only had a 1 or 0 returned from Imagemagick using php so I do not know were the 4 is coming from.

I have used similar code to yours but have never used escapeshellcmd in the exec. The exec is calling an external program and I am not sure you can use it there.

Try( notice the input image comes right after the convert in most cases ):

exec("convert $file_name.png -resize 150% res_$file_name.png");

You can validate your input and output image filenames before sending them to exec()

Different error reporting:

$array=array();
echo "<pre>";
exec("convert $file_name.png -resize 150% res_$file_name.png 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";

answered May 29, 2018 at 11:40

Bonzo's user avatar

BonzoBonzo

5,1491 gold badge19 silver badges27 bronze badges

6

Понравилась статья? Поделить с друзьями:

Не пропустите эти материалы по теме:

  • Яндекс еда ошибка привязки карты
  • Imageeng exe обнаружена ошибка при сканировании
  • Image capture plus ошибка чтения
  • Image capture plus ошибка 10060
  • Imacros игнорировать ошибки

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии