Clipping paths

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
KaLa
Posts: 2
Joined: 2015-03-20T06:43:11-07:00
Authentication code: 6789

Clipping paths

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Clipping paths

Post 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.
snibgo's IM pages: im.snibgo.com
KaLa
Posts: 2
Joined: 2015-03-20T06:43:11-07:00
Authentication code: 6789

Re: Clipping paths

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Clipping paths

Post 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.
snibgo's IM pages: im.snibgo.com
Post Reply