Help with clip path and tif

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
gent99
Posts: 3
Joined: 2017-06-29T05:35:12-07:00
Authentication code: 1151

Help with clip path and tif

Post by gent99 »

Hi,

i've a problem here with clip path in tif-files. According to this site here.

http://www.imagemagick.org/Usage/masking/#clip-path

this should work to use the clip path for removing the background:

Code: Select all

convert input.tiff -alpha transparent -clip -alpha opaque -strip out.tiff
in my case i'm using this command here to do the same

Code: Select all

convert -colorspace sRGB 3960666_TRIO_H_00.tif -alpha transparent -clip -alpha opaque -strip tmp1.jpg
The source image is a cmyk-tif with a clip path. It's available here for testing:
https://www.dropbox.com/s/5hxxbybyi01ho ... 0.tif?dl=0

The resulting jpg is here:
https://www.dropbox.com/s/xht8u24wj60yyit/tmp1.jpg?dl=0

Unfortunately i'm not able to remove the image's background.

I've tested this with the following versions and os:
7.0.5-5 Q16 x86_64 2017-04-25 on macOS
7.0.5-6 Q16 x86_64 2017-05-14 on RHEL7
6.7.2-7 2015-07-23 on CentOS

Is there an IM evangelist around who could see, what i'm doing wrong? Is it even possible to do what i want?

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

Re: Help with clip path and tif

Post by fmw42 »

It is a very simple problem. JPEG does not support transparency. Change your output to PNG. Your image also has a CMYK profile, so using profiles to convert to sRGB is better than using -colorspace. Change the path to your profiles as needed

Code: Select all

convert -quiet 3960666_TRIO_H_00.tif -profile /Users/fred/images/profiles/sRGB.icc -alpha transparent -clip -alpha opaque -strip 3960666_TRIO_H_00.png
Image

Or if you want to use JPG, then you must change the transparency to some color, say white:

Code: Select all

convert -quiet 3960666_TRIO_H_00.tif -profile /Users/fred/images/profiles/sRGB.icc -alpha transparent -clip -alpha opaque -alpha opaque -strip PNG:- | convert - -background white -alpha background -alpha off 3960666_TRIO_H_00.jpg
Image
gent99
Posts: 3
Joined: 2017-06-29T05:35:12-07:00
Authentication code: 1151

Re: Help with clip path and tif

Post by gent99 »

Hello Fred,

I tried

Code: Select all

convert -quiet 3960666_TRIO_H_00.tif -profile /usr/local/share/colors/icc/AppleRGB.icc -alpha transparent -clip -alpha opaque -strip 3960666_TRIO_H_00.png
unfortunately this does not work so well. My resulting png looks like this:

https://www.dropbox.com/s/75gc422pmc7v2 ... 0.png?dl=0

The jpeg version looks the same...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with clip path and tif

Post by fmw42 »

What version of ImageMagick produces your bad result?

You list
7.0.5-5 Q16 x86_64 2017-04-25 on macOS
7.0.5-6 Q16 x86_64 2017-05-14 on RHEL7
6.7.2-7 2015-07-23 on CentOS

Do they all fail or just the 6.7.2.7 which is ancient? Note for IM 7 versions you need to replace "convert" with "magick".


My command works fine for IM 6.9.8.10 Q16 Mac OSX and IM 7.0.6.1 Q16 Mac OSX. It also works for IM 6.7.8.9 Q16 Mac OSX. Sorry I cannot go back as far as 6.7.2.7.

IM6

Code: Select all

convert -quiet 3960666_TRIO_H_00.tif -profile /Users/fred/images/profiles/sRGB.icc -alpha transparent -clip -alpha opaque -strip 3960666_TRIO_H_00.png
IM7

Code: Select all

magick -quiet 3960666_TRIO_H_00.tif -profile /Users/fred/images/profiles/sRGB.icc -alpha transparent -clip -alpha opaque -strip 3960666_TRIO_H_00.png
I would suggest you try upgrading to more current versions of ImageMagick.
gent99
Posts: 3
Joined: 2017-06-29T05:35:12-07:00
Authentication code: 1151

Re: Help with clip path and tif

Post by gent99 »

Hi Fred,

thanks again. I tested on 6.7.2-7 2015-07-23 on CentOS just because i have this version on an older VM. I did not actually use this version. I also tested the magick command instead of convert. Unfortunately the result ist still the same on mac with 7.0.5-5 Q16 x86_64. I'll try to get 7.0.6.1 (or perhaps 6.9.8.10 Q16) and will test again.

Kind regards, Holger
Post Reply