Page 1 of 1

Problem with removing the background by clipping path

Posted: 2020-03-25T04:12:20-07:00
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

Re: Problem with removing the background by clipping path

Posted: 2020-03-25T09:49:57-07:00
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

Re: Problem with removing the background by clipping path

Posted: 2020-03-25T10:16:59-07:00
by snibgo

Re: Problem with removing the background by clipping path

Posted: 2020-03-26T07:32:09-07:00
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?

Re: Problem with removing the background by clipping path

Posted: 2020-03-26T07:47:49-07:00
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?

Re: Problem with removing the background by clipping path

Posted: 2020-03-26T08:11:00-07:00
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.

Re: Problem with removing the background by clipping path

Posted: 2020-03-27T03:16:35-07:00
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

Re: Problem with removing the background by clipping path

Posted: 2020-03-27T09:41:36-07:00
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?

Re: Problem with removing the background by clipping path

Posted: 2020-03-27T15:50:01-07:00
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