Mogrify, on fail - delete

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
sergeda
Posts: 3
Joined: 2013-07-17T05:49:07-07:00
Authentication code: 6789

Mogrify, on fail - delete

Post by sergeda »

I'm having folder with pictures in subdirs. I want to change the width of all pictures. For this I use command:

Code: Select all

find . \( -name "*.jpg" -o -name "*.png" \) -exec mogrify -thumbnail 250 * {} \;
This working fine exept there are some incorrect files at wich mogrify complains.
I would like to delete those bad files if mogrify can't resize them. Is it possible?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify, on fail - delete

Post by fmw42 »

Post an example image that mogrify will not process. Do you know why it fails? Is the file corrupt? Can you process the file with convert rather than mogrify?

Can you get results from

identify yourimage

If that fails, then you would be able to identify such files by looping over each file in your directory and testing whether identify fails or not. Get rid of all those files. Then use your command with mogrify on all the good files.
sergeda
Posts: 3
Joined: 2013-07-17T05:49:07-07:00
Authentication code: 6789

Re: Mogrify, on fail - delete

Post by sergeda »

fmw42 wrote:Post an example image that mogrify will not process. Do you know why it fails? Is the file corrupt? Can you process the file with convert rather than mogrify?

Can you get results from

identify yourimage

If that fails, then you would be able to identify such files by looping over each file in your directory and testing whether identify fails or not. Get rid of all those files. Then use your command with mogrify on all the good files.
There are just number of corrupted images. I like your idea to identify and delete failed images first but don't know how to acomplish this.
This will identify all files:

Code: Select all

find . "*" -exec identify {} \;
but how to add verification of results and delete part I don't know.
Please help someone more expririenced with shell scripts.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify, on fail - delete

Post by fmw42 »

First let us know if identify fails for your bad images. Or provide a link to one example that fails so we can figure out the best way to test them and remove them.
sergeda
Posts: 3
Joined: 2013-07-17T05:49:07-07:00
Authentication code: 6789

Re: Mogrify, on fail - delete

Post by sergeda »

fmw42 wrote:First let us know if identify fails for your bad images. Or provide a link to one example that fails so we can figure out the best way to test them and remove them.
Yes, identity fails for that images.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify, on fail - delete

Post by fmw42 »

sergeda wrote:
fmw42 wrote:First let us know if identify fails for your bad images. Or provide a link to one example that fails so we can figure out the best way to test them and remove them.
Yes, identity fails for that images.
Can you provide the error message or how it fails? It would be best to provide a link to one image that fails, so we can test and come up with a loop that will delete or move those images to another directory.
Post Reply