implode region in IM 7

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

implode region in IM 7

Post by dognose »

Not sure if this is a bug or if changes in implode or how region works in IM 7

Any idea on what's going on or how to fix?

flower.jpg
Image

convert -region '150x150+50+50' -implode 1 flower.jpg out.jpg
IM 6 out.jpg (desired)
Image

magick flower.jpg -region '150x150+50+50' -implode 1 out.jpg
IM 7 out.jpg ( notice box effect)
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: implode region in IM 7

Post by magick »

See https://imagemagick.org/script/porting.php:
-region: This option sets a write mask for the region you define. In IMv6, a separate image was cloned instead, operated on, and the results were composited to the source image. In addition, the draw transformations are relative to the upper left corner of the image, previously in IMv6 they were relative to the region.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: implode region in IM 7

Post by fmw42 »

Thanks. Is there a workaround other than compositing with a mask image?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: implode region in IM 7

Post by magick »

Sure, you can clone the image, operate on it and composite the results back to the source image. This is exactly what IMv6 does, -region was simply a convenience to do all the operations with one -region option.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: implode region in IM 7

Post by fmw42 »

These are equivalent. (Note proper IM syntax -- read the input first)

Code: Select all

convert flower.jpg -region '150x150+50+50' -implode 1 +region out.jpg

Code: Select all

convert flower.jpg \
\( -clone 0 -crop '150x150+50+50' +repage -implode 1 \) \
-geometry +50+50 -composite result6.jpg

Code: Select all

magick flower.jpg \
\( -clone 0 -crop '150x150+50+50' +repage -implode 1 \) \
-geometry +50+50 -composite result7.jpg
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: implode region in IM 7

Post by dognose »

Thanks so much!
Post Reply