Using mogrify to strip rubbish from image files with loss

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
hollymcr
Posts: 9
Joined: 2009-12-01T03:56:35-07:00
Authentication code: 8675309

Using mogrify to strip rubbish from image files with loss

Post by hollymcr »

I'm looking to post-process files recovered from corrupt/damaged disks using photorec. One of the problems with its type of recovery is that it can't always detect the end of a file, and so (for example) an 500byte .gif file might be recovered as a 1.5GB file...

If I run:

Code: Select all

mogrify recovered.gif
.. then I get the 500 byte file back.

My question is: What options do I need to give mogrify, in the general case (ideally for all image types that it supports, but certainly common ones like jpg,png,gif) to ensure that all it does is load the file and save an identical copy (other than stripping off the rubbish). I don't want to lose meta data or re-encode/re-compress the image in any way. Indeed, is it sufficient to just not tell it to do anything (as above) to be sure that it does nothing, which would normally be pointless but in this case extremely useful?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using mogrify to strip rubbish from image files with los

Post by snibgo »

I don't think IM ever guarantees to copy all the metadata. Exiftool might do what you want, either by itself, or using exiftool to copy all the metadata, IM to convert it, and exiftool to restore the metadata. Or convert with IM, then use exiftool to copy metadata from the corrupt file to the new one.
snibgo's IM pages: im.snibgo.com
Post Reply