Page 1 of 1

Problem with distort the line in different areas

Posted: 2019-02-03T13:24:04-07:00
by batjka911
I'm use Linux.

Code: Select all

magick -version    
Version: ImageMagick 7.0.8-25 Q16 x86_64 2019-01-28 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP 
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
I tried to reproduce the examples on this page:https://imagemagick.org/Usage/masking/#region_warping

Code: Select all

magick -size 600x70 xc:white -fill black -draw 'rectangle 5,25 595,31'\
-fill red -draw 'rectangle 5,39 595,45' lines.jpg
But when I apply -region with -swirl

Code: Select all

magick lines.jpg -region 90x70+10+0 -swirl 400 reg_lines.jpg
then this is the result and it's different from examples.
https://imgur.com/u267APA

And if i repeat the command completely it looks awful.

It's something I'm doing wrong?

Re: Problem with distort the line in different areas

Posted: 2019-02-03T13:40:01-07:00
by fmw42
-region behaves differently in IM 7 than in IM 6. See https://imagemagick.org/script/porting.php#cli. These are different for me using IM 6.9.10.25 and IM 7.0.8.25.

Code: Select all

magick lines.gif \
-region 90x70+10+0    -swirl  400  \
-region 90x70+100+0   -swirl  400 \
-region 90x70+190+0   -swirl -400 \
-region 120x70+280+0  -implode 1.5 \
-region 100x70+380+0  -implode -7  \
-region 101x70+480+0  -wave 10x50 -crop 0x70+0+10\! \
+region lines_regions.gif

magick lines.gif -region 90x70+10+0 -swirl 400 +region reg_lines7.jpg

convert lines.gif -region 90x70+10+0 -swirl 400 +region reg_lines6.jpg

However, I am not sure how to get the same result as in the link with IM 7 using -regon. (One could just create a mask and use that to process). It is clearly the region issue, since -swirl gives the same results as per

Code: Select all

magick -size 600x70 xc:darkred \
-fill white -draw 'roundrectangle 5,5  595,65 5,5' \
-fill black -draw 'rectangle 5,25 595,31' \
-fill red -draw 'rectangle 5,39 595,45' \
lines.gif

convert lines.gif -crop 90x70+10+0 +repage -swirl 400 swirl6.jpg

magick  lines.gif -crop 90x70+10+0 +repage -swirl 400 swirl7.jpg

So another solution would be to crop the region, do the swirl, then composite the processed image back.

As per the porting notes, I am not sure -region can be used with IM 7 to do what it did in IM 6.

Re: Problem with distort the line in different areas

Posted: 2019-02-03T14:28:13-07:00
by batjka911
Thanks for the quick response
fmw42 wrote:So another solution would be to crop the region, do the swirl, then composite the processed image back.
and practical advice.

I am not a Linux guru to integrate two versions IM on one computer. Therefore, I will try to use KNOPPIX for various experiments. True in DEBIAN last stable version 6.9.7.4

And thanks again.

Re: Problem with distort the line in different areas

Posted: 2019-02-03T16:40:18-07:00
by GeeMack
batjka911 wrote: 2019-02-03T14:28:13-07:00 Thanks for the quick response
fmw42 wrote:So another solution would be to crop the region, do the swirl, then composite the processed image back.
and practical advice.
To crop an region, do some operations on it, then composite it back on the original as fmw42 suggested can be pretty simple. This command...

Code: Select all

magick lines.jpg \( +clone -crop 90x70+10+0 -swirl 400 \) -flatten reg_lines.jpg
... does exactly that. Inside the parentheses it clones the input image, crops the specified region, and swirls just that piece. The cropped and swirled piece conveniently hangs on to its original offsets, so when you flatten it back onto the input image, it places it at its original location.

Re: Problem with distort the line in different areas

Posted: 2019-02-04T01:35:42-07:00
by batjka911
GeeMack wrote: 2019-02-03T16:40:18-07:00
To crop an region, do some operations on it, then composite it back on the original as fmw42 suggested can be pretty simple. This command...

Code: Select all

magick lines.jpg \( +clone -crop 90x70+10+0 -swirl 400 \) -flatten reg_lines.jpg
... does exactly that. Inside the parentheses it clones the input image, crops the specified region, and swirls just that piece. The cropped and swirled piece conveniently hangs on to its original offsets, so when you flatten it back onto the input image, it places it at its original location.
Thanks,exactly what the doctor ordered.