]> granicus.if.org Git - imagemagick/commitdiff
The read method in Magick++ will raise a warning when it fails to read an image but...
authordirk <dirk@git.imagemagick.org>
Sat, 9 Aug 2014 20:50:48 +0000 (20:50 +0000)
committerdirk <dirk@git.imagemagick.org>
Sat, 9 Aug 2014 20:50:48 +0000 (20:50 +0000)
Magick++/lib/Image.cpp
Magick++/lib/Magick++/Image.h

index 168f57cb5befe4f4a5d81f5519d844843c956264..5eb2b53afa3aefbc8635d0cd54c22b57c902b9ca 100644 (file)
@@ -3882,8 +3882,7 @@ void Magick::Image::read(const Blob &blob_)
   GetPPException;
   newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
     blob_.length(),exceptionInfo);
-  replaceImage(newImage);
-  ThrowPPException;
+  read(newImage,exceptionInfo);
 }
 
 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
@@ -3948,21 +3947,7 @@ void Magick::Image::read(const std::string &imageSpec_)
   GetPPException;
   options()->fileName(imageSpec_);
   newImage=ReadImage(imageInfo(),exceptionInfo);
-
-  // Ensure that multiple image frames were not read.
-  if (newImage && newImage->next)
-    {
-      MagickCore::Image
-         *next;
-
-      // Destroy any extra image frames
-      next=newImage->next;
-      newImage->next=0;
-      next->previous=0;
-      DestroyImageList(next);
-    }
-  replaceImage(newImage);
-  ThrowPPException;
+  read(newImage,exceptionInfo);
 }
 
 void Magick::Image::readPixels(const Magick::QuantumType quantum_,
@@ -4997,6 +4982,32 @@ void Magick::Image::unregisterId(void)
   _imgRef->id(-1);
 }
 
+void Magick::Image::read(MagickCore::Image *image,
+  MagickCore::ExceptionInfo *exceptionInfo)
+{
+  // Ensure that multiple image frames were not read.
+  if (image != (MagickCore::Image *) NULL &&
+      image->next != (MagickCore::Image *) NULL)
+    {
+      MagickCore::Image
+        *next;
+
+      // Destroy any extra image frames
+      next=image->next;
+      image->next=(MagickCore::Image *) NULL;
+      next->previous=(MagickCore::Image *) NULL;
+      DestroyImageList(next);
+    }
+  replaceImage(image);
+  if (exceptionInfo->severity == MagickCore::UndefinedException &&
+      image == (MagickCore::Image *) NULL)
+    {
+      (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
+      throwExceptionExplicit(ImageWarning,"No image was loaded.");
+    }
+  ThrowPPException;
+}
+
 void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
   const Magick::Image *fillPattern_,const Magick::Color &fill_,
   const MagickCore::PixelInfo *target_,const bool invert_)
index d83c1f61c199b6a2ea64d80ea54967de22df713e..be45d57b338ffc4caa1bd77205dac1ffac36fd19 100644 (file)
@@ -1495,6 +1495,9 @@ namespace Magick
 
   private:
 
+    void read(MagickCore::Image *image,
+      MagickCore::ExceptionInfo *exceptionInfo);
+
     void floodFill(const ssize_t x_,const ssize_t y_,
       const Magick::Image *fillPattern_,const Color &fill_,
       const PixelInfo *target,const bool invert_);