"Error 0x80070057: The parameter is incorrect" when editing JPEG metadata
I don't know the root cause of this error, but it seems to have something to do with the file itself. Using exiftool to repair corrupted EXIF seems to fix the problem. The command looks like this:
exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile bad.jpg
More detail on what this does:
This command deletes all metadata then copies all writable tags that can be extracted from the original image to the same locations in the updated image. The "Unsafe" tag is a shortcut for unsafe EXIF tags in JPEG images which are not normally copied. JPEG images may also contain an ICC color profile which should be preserved. The "ICC_Profile" tag is also marked as unsafe, but is not part of the EXIF so it isn't covered by the "Unsafe" shortcut and must be specified separately.
Note: ExifTool will not modify the JPEG image data.
Advanced: The byte order of the newly created EXIF is set by the value of the ExifByteOrder tag. If ExifByteOrder is not set then the byte order is determined by the ordering of the MakerNotes if they are copied, otherwise big-endian ("MM") byte order is used by default. ExifByteOrder may be set to a specific value to force a particular byte order when creating new EXIF (eg. "-ExifByteOrder=II" for little-endian).
Note also that running the above command on a file named bad.jpg
will preserve a copy of the original file under the filename bad.jpg_original
.