M
M
Mikhail Deynekin2015-06-09 23:00:00
linux
Mikhail Deynekin, 2015-06-09 23:00:00

What program is there for Linux to find broken pictures/images?

Which program under Linux looks for broken images?
When optimizing images, I came across the fact that there are a lot of broken images on the site, but how to remove them in one fell swoop?
Run command

find /var/www -name "*.gif" -print0 | xargs -0 ~/usr/bin/gifsicle-1.87/src/gifsicle -b -O3

gives out:
gifsicle:/var/www/photos/28060fr02.gif: read error: image corrupted, code out of range (4 times)
gifsicle:/var/www/photos/28060fr02.gif: read error: missing 8089 pixels of image data
gifsicle :/var/www/photos/97529fr02.gif: read error: image corrupted, code out of range (20 times)
gifsicle:/var/www/photos/97529fr02.gif: read error: (not reporting more errors)

But gifsicle doesn't know how to delete bad files.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Deynekin, 2015-06-09
@paulmann

No, -I produces the same result on broken and intact images:
Integer:
-bash-4.1# ~/usr/bin/gifsicle-1.87/src/gifsicle -I /var/www/paulmann/data/www/paulmann.su/photos/28060fr02.gif
* /var/www/paulmann/data/ www/paulmann.su/photos/28060fr02.gif 1 image
logical screen 120x70
global color table [256]
background 0
+ image #0 120x70
Broken:
-bash-4.1# ~/usr/bin/gifsicle-1.87/src/gifsicle -I /var/www/paulmann/data/www/paulmann.su/photos/28060bad.gif
* /var/www/paulmann/data/ www/paulmann.su/photos/28060bad.gif 1 image
logical screen 120x70
global color table [256]
background 0
+ image #0 120x70
and only by running the optimization we have:

gifsicle:/var/www/paulmann/data/www/paulmann.su/photos/28060bad.gif: read error: image corrupted, code out of range (4 times)
gifsicle:/var/www/paulmann/data/www/ paulmann.su/photos/28060bad.gif: read error: missing 8089 pixels of image data

Thanks to Valery Ryaboshapko - for your solution to work, you need to use "-O3" instead of "-I", because the beaten file is defined only at a compression. Removed everything that the program cursed during optimization (if the optimization is successful, gifsicle does not display anything):
PS At the same time, except for the broken ones, JPG files with the GIF extension and all other files with which at least something is not right will be deleted.

V
Valery Ryaboshapko, 2015-06-09
@valerium

It is almost certain that gifsicle will return a non-zero exit code when it encounters a bad image. Using this information, you can easily create a script that will remove broken images.
Something like this, but you need to test before executing on real data.

for i in `find /var/www -name "*.gif"`; do
    ~/usr/bin/gifsicle-1.87/src/gifsicle -I $i > /dev/null || rm $i
done

S
SagePtr, 2015-06-10
@SagePtr

If the pictures were broken in some way, I would not trust the surviving pictures from the same source. After all, some pictures could be beaten in such a way that they would not differ from the surviving ones or even be overwritten with other pictures.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question