Skip to content

JPEG: Automatically check and repair broken/invalid images #2463

@lastzero

Description

@lastzero

Go happily refuses to open JPEGs if they contain any glitches. As a user with such files, you still want to index and view them. It would therefore make sense to automate the repair of JPEGs, especially since the process is always the same.

Step 1: Use GraphicsMagick to check a JPEG for issues

GraphicsMagick is a great tool for this task. Depending on what operating system you are using, you may need to install it first: http://www.graphicsmagick.org/identify.html

Now run this command and check the report for any problems:

gm identify -verbose broken.jpg

Note that ImageMagick may also have a command for this. This describes the specific process I used and that worked for me. There are variants and it can likely be optimized so that fewer tools and libraries need to be installed.

Step 2: Use the ImageMagick convert command to create a valid copy of the image

To create a valid copy of the original JPEG:

convert broken.jpg fixed.jpg

Any glitches should then be fixed i.e. the repaired copy fixed.jpg can be opened without problems.

Related Issues:

Metadata

Metadata

Assignees

Labels

ideaFeedback wanted / feature requestreleasedAvailable in a stable releaseuxImpacts User Experience

Type

No type
No fields configured for issues without a type.

Projects

Status
Release 🌈

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions