Problem with removing the background by clipping path

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.
Locked
ite@4allportal
Posts: 6
Joined: 2020-03-25T03:11:29-07:00
Authentication code: 1152

Problem with removing the background by clipping path

Post by ite@4allportal »

I try to remove the background by clipping path with the ImageMagick of the version 7.0.x.
I have tried some different version: 7.0.9-22, 7.0.10-0 and 7.0.10-2 on the different systems.

So this call gave a whole transparent picture:

Code: Select all

convert -verbose ~/Downloads/rechteck.psd[0] -alpha transparent -clip -alpha opaque  +repage  ~/Downloads/rechteck.png
If i try this with ImageMagick 6.9.11-0, i get the correct result.

Another question: does the ImageMagick support multiple clipping path by "-clip" command? I want to remove the background by all clipping paths.

https://drive.google.com/file/d/1KW2-Na ... sp=sharing

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with removing the background by clipping path

Post by fmw42 »

As far as I know, ImageMagick only deals with one clip path at a time.

I can confirm that this does not work on IM 7.0.10.2 Q16, but does work in IM 6.9.11.2. This seems to be a bug.

Code: Select all

magick rechteck.psd[0] -alpha transparent -clip -alpha opaque  +repage  result.png
However, this does work:

Code: Select all

magick identify -format "%[8BIM:1999,2998:#1]" rechteck.psd[0] |\
magick -quiet rechteck.psd[0] +repage \
\( - -channel rgb -negate \) \
-alpha off -compose copy_opacity -composite \
result2.png

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problem with removing the background by clipping path

Post by snibgo »

snibgo's IM pages: im.snibgo.com

ite@4allportal
Posts: 6
Joined: 2020-03-25T03:11:29-07:00
Authentication code: 1152

Re: Problem with removing the background by clipping path

Post by ite@4allportal »

fmw42 wrote:
2020-03-25T09:49:57-07:00
As far as I know, ImageMagick only deals with one clip path at a time.

I can confirm that this does not work on IM 7.0.10.2 Q16, but does work in IM 6.9.11.2. This seems to be a bug.

Code: Select all

magick rechteck.psd[0] -alpha transparent -clip -alpha opaque  +repage  result.png
However, this does work:

Code: Select all

magick identify -format "%[8BIM:1999,2998:#1]" rechteck.psd[0] |\
magick -quiet rechteck.psd[0] +repage \
\( - -channel rgb -negate \) \
-alpha off -compose copy_opacity -composite \
result2.png
Thank you for suggestion. Will the bug be fixed soon?

ite@4allportal
Posts: 6
Joined: 2020-03-25T03:11:29-07:00
Authentication code: 1152

Re: Problem with removing the background by clipping path

Post by ite@4allportal »

snibgo wrote:
2020-03-25T10:16:59-07:00
For multiple clipping paths, see https://www.imagemagick.org/script/comm ... #clip-path .
I have already seen it. What do I do if I don't know how many clipping paths an image has?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Problem with removing the background by clipping path

Post by snibgo »

Code: Select all

exiftool -args -ClippingPathName *.jpg
That should do it, but I don't have any multi-clip-path files to test it on.
snibgo's IM pages: im.snibgo.com

ite@4allportal
Posts: 6
Joined: 2020-03-25T03:11:29-07:00
Authentication code: 1152

Re: Problem with removing the background by clipping path

Post by ite@4allportal »

snibgo wrote:
2020-03-26T08:11:00-07:00

Code: Select all

exiftool -args -ClippingPathName *.jpg
That should do it, but I don't have any multi-clip-path files to test it on.
Can you help me to remove background by all clipping paths in this file:

https://drive.google.com/file/d/1_A1ZBw ... sp=sharing

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with removing the background by clipping path

Post by fmw42 »

I am not sure I know what you expect. It looks like each layer has a its own clip path when looking at the verbose information. So just loop over each layer and remove the clip path and then merge the results.

Unix syntax for IM 7

Code: Select all

num_layers=`magick convert rechteck2.psd -format "%n\n" info: | head -n 1`
for ((i=0; i<num_layers; i++ )); do
magick identify -format "%[8BIM:1999,2998:#1]" rechteck2.psd[$i] | \
magick -quiet rechteck2.psd[$i] +repage \
\( - -channel rgb -negate \) \
-alpha off -compose copy_opacity -composite \
result$i.png
done
magick result*.png -background none -flatten rechteck2.png
rm -f result*.png
Image

If this is not correct, then can you post the expected result?

ite@4allportal
Posts: 6
Joined: 2020-03-25T03:11:29-07:00
Authentication code: 1152

Re: Problem with removing the background by clipping path

Post by ite@4allportal »

fmw42 wrote:
2020-03-27T09:41:36-07:00
If this is not correct, then can you post the expected result?
No, it's not what I'm expecting.

https://drive.google.com/file/d/17QoCBg ... sp=sharing

Locked