Page 1 of 1

Clipping paths

Posted: 2015-03-20T07:00:41-07:00
by KaLa
Hi guys,
I could really use som help with this...

I have a huge archive of images, some of them contain clipping paths - and some don't. Want I want is a command line that will process clipping when a path is present - and when it is not --> to continue with the rest of the parameters and complete the operation (without throwing an error).

This command line works fine for images with clip paths...
convert image.tif -alpha transparent -clip -alpha opaque -strip -resize 800x800 -background white -flatten image.jpg

However, when this command line encounters images without clip paths, then it throws an error ("no clip path defined `image.tif': No such file or directory @ error/image.c/ClipImagePath/719") and the operation fails.


Does anyone know of a way around this?

Cheers,
Kare

Re: Clipping paths

Posted: 2015-03-20T12:38:52-07:00
by snibgo
Your script could catch this error and run an alternative command. Or it could run "identify -verbose" first to determine whether a clip path is present.

Re: Clipping paths

Posted: 2015-03-24T01:41:55-07:00
by KaLa
snibgo wrote:Your script could catch this error and run an alternative command. Or it could run "identify -verbose" first to determine whether a clip path is present.
I'm using IM through an external tool connector from a DAM system and can only pass "one liners" to IM..

Example:
C:\Program Files\ImageMagick-6.9.0-Q16\convert.exe $INPUT -alpha transparent -clip -alpha opaque -strip -resize 800x800 -background white -flatten $OUTPUT.jpg

How can I pass an "if statement" and run alternate commands if a clip path is not present?

I would be very greatful for any tips.

Cheers,
Kare

Re: Clipping paths

Posted: 2015-03-24T02:28:25-07:00
by snibgo
I don't know what a DAM system is.

If it can't run a script, and can only run a binary program, then you could write a program, a customised version of convert. It would either ignore that particular error, or do one of the actions I mentioned above.