diff --git a/MagickCore/image.c b/MagickCore/image.c
index b51c52d..ebd487e 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -1058,11 +1058,13 @@
assert(source_image != (Image *) NULL);
assert(geometry != (RectangleInfo *) NULL);
assert(offset != (OffsetInfo *) NULL);
- if ((geometry->width == 0) || (geometry->height == 0) || (offset->x < 0) ||
- (offset->y < 0) || (offset->x >= (ssize_t) geometry->width) ||
- (offset->y >= (ssize_t) geometry->height))
+ if ((offset->x < 0) || (offset->y < 0) ||
+ ((offset->x+geometry->width) >= (ssize_t) image->columns) ||
+ ((offset->y+geometry->height) >= (ssize_t) image->rows))
ThrowBinaryException(OptionError,"GeometryDoesNotContainImage",
image->filename);
+ if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
+ return(MagickFalse);
/*
Copy image pixels.
*/
diff --git a/MagickWand/convert.c b/MagickWand/convert.c
index 690b33d..232bec7 100644
--- a/MagickWand/convert.c
+++ b/MagickWand/convert.c
@@ -1181,7 +1181,6 @@
ThrowConvertException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowConvertInvalidArgumentException(option,argv[i]);
- i++;
break;
}
if (LocaleCompare("crop",option+1) == 0)
diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c
index 977527a..708199a 100644
--- a/MagickWand/mogrify.c
+++ b/MagickWand/mogrify.c
@@ -1265,29 +1265,6 @@
kernel_info=DestroyKernelInfo(kernel_info);
break;
}
- if (LocaleCompare("copy",option+1) == 0)
- {
- Image
- *source_image;
-
- OffsetInfo
- offset;
-
- /*
- Copy image pixels.
- */
- (void) SyncImageSettings(mogrify_info,*image,exception);
- flags=ParsePageGeometry(*image,argv[i+2],&geometry,exception);
- offset.x=geometry.x;
- offset.y=geometry.y;
- flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
- source_image=(*image);
- if ((*image)->next != (Image *) NULL)
- source_image=(*image)->next;
- status=CopyImagePixels(*image,source_image,&geometry,&offset,
- exception);
- break;
- }
if (LocaleCompare("crop",option+1) == 0)
{
/*
@@ -4393,7 +4370,6 @@
ThrowMogrifyException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowMogrifyInvalidArgumentException(option,argv[i]);
- i++;
break;
}
if (LocaleCompare("crop",option+1) == 0)
@@ -7873,6 +7849,33 @@
*images=image;
break;
}
+ if (LocaleCompare("copy",option+1) == 0)
+ {
+ Image
+ *source_image;
+
+ OffsetInfo
+ offset;
+
+ RectangleInfo
+ geometry;
+
+ /*
+ Copy image pixels.
+ */
+ (void) SyncImageSettings(mogrify_info,*images,exception);
+ (void) ParsePageGeometry(*images,argv[i+2],&geometry,exception);
+ offset.x=geometry.x;
+ offset.y=geometry.y;
+ source_image=(*images);
+ if (source_image->next != (Image *) NULL)
+ source_image=source_image->next;
+ (void) ParsePageGeometry(source_image,argv[i+1],&geometry,
+ exception);
+ status=CopyImagePixels(*images,source_image,&geometry,&offset,
+ exception);
+ break;
+ }
break;
}
case 'd':
diff --git a/MagickWand/operation.c b/MagickWand/operation.c
index a3bc47e..14a3ec7 100644
--- a/MagickWand/operation.c
+++ b/MagickWand/operation.c
@@ -2165,32 +2165,6 @@
kernel_info=DestroyKernelInfo(kernel_info);
break;
}
- if (LocaleCompare("copy",option+1) == 0)
- {
- Image
- *source_image;
-
- OffsetInfo
- offset;
-
- /*
- Copy image pixels.
- */
- if (IfMagickFalse(IsGeometry(arg1)))
- CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
- if (IfMagickFalse(IsGeometry(arg2)))
- CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
- flags=ParsePageGeometry(_image,arg2,&geometry,exception);
- offset.x=geometry.x;
- offset.y=geometry.y;
- flags=ParsePageGeometry(_image,arg1,&geometry,exception);
- source_image=_image;
- if (_image->next != (Image *) NULL)
- source_image=_image->next;
- (void) CopyImagePixels(_image,source_image,&geometry,&offset,
- exception);
- break;
- }
if (LocaleCompare("crop",option+1) == 0)
{
/* WARNING: This can generate multiple images! */
@@ -3897,6 +3871,35 @@
source_image=DestroyImage(source_image);
break;
}
+ if (LocaleCompare("copy",option+1) == 0)
+ {
+ Image
+ *source_image;
+
+ OffsetInfo
+ offset;
+
+ RectangleInfo
+ geometry;
+
+ /*
+ Copy image pixels.
+ */
+ if (IfMagickFalse(IsGeometry(arg1)))
+ CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+ if (IfMagickFalse(IsGeometry(arg2)))
+ CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1);
+ (void) ParsePageGeometry(_images,arg2,&geometry,_exception);
+ offset.x=geometry.x;
+ offset.y=geometry.y;
+ (void) ParsePageGeometry(_images,arg1,&geometry,_exception);
+ source_image=_images;
+ if (source_image->next != (Image *) NULL)
+ source_image=source_image->next;
+ (void) CopyImagePixels(_images,source_image,&geometry,&offset,
+ _exception);
+ break;
+ }
CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option);
}
case 'd':