Page 1 of 1

[solved] clippath on png not working

Posted: 2009-05-14T00:50:47-07:00
by kriks
Hi,

to workaround the fact that ghostscript can't handle CMYKA images, I first generate a RGB PNG with the profiles, the colors are good but the background is white.

Now, I would like to extract the outer part of the clip path which is still inside the PNG,

I use :

Code: Select all

convert -verbose 841267_test.png -alpha On -fill none -clip 841267_test2.png
but the background remains white.

here is a identify -verbose on 841267_test.png :

Code: Select all

# identify -verbose 841267_test.png
Image: 841267_test.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 2158x1600+0+0
  Resolution: 300x300
  Print size: 7.19333x5.33333
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: RGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    red:
      min: 23 (0.0901961)
      max: 255 (1)
      mean: 238.012 (0.933381)
      standard deviation: 26.8681 (0.105365)
      kurtosis: 2.39327
      skewness: -1.65476
    green:
      min: 5 (0.0196078)
      max: 255 (1)
      mean: 204.667 (0.802616)
      standard deviation: 71.7491 (0.281369)
      kurtosis: -0.60666
      skewness: -0.99568
    blue:
      min: 0 (0)
      max: 255 (1)
      mean: 184.649 (0.724113)
      standard deviation: 95.2691 (0.373604)
      kurtosis: -1.17866
      skewness: -0.761039
  Image statistics:
    OverAll:
      min: 0 (0)
      max: 255 (1)
      mean: 156.832 (0.615027)
      standard deviation: 110.899 (0.434899)
      kurtosis: -1.5821
      skewness: -0.472438
  Rendering intent: Undefined
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Page geometry: 2158x1600+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    create-date: 2009-05-12T15:58:09+02:00
    modify-date: 2009-05-12T15:58:09+02:00
    ps:HiResBoundingBox: 518x384+0+0
    ps:Level: Adobe-3.0 EPSF-3.0
    signature: 6786af6f8651f993b0adf8455559a850edbdc22eb5838e422d511550ed70173b
  Clipping path:
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="2158" height="1600">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 231.726,1048.98
C 210.736,1028.95 195.409,1017.27 176.418,984.731
C 157.427,952.19 146.932,919.149 146.932,919.149
C 146.932,919.149 135.937,911.139 130.939,906.633
C 125.942,902.128 125.442,897.622 124.442,891.614
...
M 1300.73,919.816
C 1300.73,919.816 1302.4,931.831 1295.73,939.174
C 1289.07,946.516 1271.74,952.524 1271.74,952.524
L 1277.07,956.195
C 1277.07,956.195 1298.07,948.853 1304.73,939.841
C 1311.39,930.83 1305.06,922.153 1300.73,919.816 Z
"/>
</g>
</svg>

  Profiles:
    Profile-8bim: 24012 bytes
    Profile-exif: 586 bytes
    Profile-icc: 560 bytes
      Adobe RGB (1998)
    Profile-iptc: 7 bytes
      unknown[2,0]:
    Profile-xml-code: 16774 bytes
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 1.401mb
  Number pixels: 3.293mb
  Version: ImageMagick 6.5.1-0 2009-05-11 Q16 http://www.imagemagick.org
this should work, no ?

Re: clippath on png not working

Posted: 2009-05-29T01:23:31-07:00
by kriks
up?

Re: clippath on png not working

Posted: 2009-05-29T06:12:32-07:00
by magick
Post a URL to your 841267_test.png image so we can download it and reproduce the problem.

Re: clippath on png not working

Posted: 2009-06-02T00:50:57-07:00
by kriks
here is the image : http://www.pingroom.net/841267_test.png

thanks for having a look!

Re: clippath on png not working

Posted: 2009-06-02T06:11:49-07:00
by magick
Try this command:
  • convert -verbose 841267_test.png -alpha on -transparent white -clip 841267_test2.png

Re: clippath on png not working

Posted: 2009-06-02T08:50:32-07:00
by kriks
it's "kind of working", but not as we want.

the command line you gave gives the same result, with or without the -clip option, which seems to mean that it will try to transform every white pixel with a transparent one, event if it's not in the clip path, which is not what we need.

is it impossible ?

Re: clippath on png not working

Posted: 2009-06-02T09:27:02-07:00
by magick
Try these commands:
  • convert 841267_test.png -clip -negate x:
    convert 841267_test.png +clip -negate x:
Notice how the negation only affects inside or outside the clipping path depending on the clip option setting.

Re: clippath on png not working

Posted: 2009-06-03T00:56:27-07:00
by kriks
Sorry but I don't understand what it means,

I tried those commands:

Code: Select all

convert 841267_test.png -clip -negate 841267_test-clip-negate.png
convert 841267_test.png +clip -negate 841267_test+clip-negate.png
convert 841267_test.png -alpha on -clip -negate 841267_test-alpha-clip-negate.png
convert 841267_test.png -alpha on +clip -negate 841267_test-alpha+clip-negate.png
the resulting files can be found at : http://pingroom.net/im/

I can see that negate affect the inside of the clip path, or all the picture, but never only the outside

Can you explain me what you wanted to show ?

Re: clippath on png not working

Posted: 2009-06-03T05:34:40-07:00
by magick
Doh! We meant to say:
  • convert 841267_test.png -clip-path #1 -negate x:
    convert 841267_test.png +clip-path #1 -negate x:

Re: clippath on png not working

Posted: 2009-06-03T06:08:21-07:00
by kriks
ok,

with

Code: Select all

convert 841267_test.png +clip-path '#1' -negate 841267_test+clip-path1-negate.png
IM gives me a black color instead of the white (following the path, I think), but what if I want transparency instead ? (RGBA)

Re: clippath on png not working

Posted: 2009-06-03T06:40:30-07:00
by magick
Try this command:
  • convert 841267_test.png +clip-path #1 -fuzz 100% -transparent white x:

Re: clippath on png not working

Posted: 2009-06-03T07:18:02-07:00
by kriks
yes, this one works, thanks!!!!!!

To made it all in one, conversion from a CMYK EPS to a RGBA PNG using a clip path looks like :

Code: Select all

convert 841267.eps -profile ISOcoated.icc -profile AdobeRGB1998.icc -depth 8 +clip-path '#1' -fuzz 100% -transparent white 841267.png
It may be useful for someone.