(In addition to Romeo Ninov's great answer)
There is an Exiftool FAQ alternative, that tries to repair JPEG file-metadata and preserve existing tags:
exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile my-image.jpg
ExifTool may be used to fix metadata problems in JPEG images by deleting all metadata and rebuilding it from scratch. [...]
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.
After repairing an image like this you should be able to write to it without errors, but note that some metadata from the original image may have been lost in the process.
Note: ExifTool will not modify the JPEG image data, so if the image itself is corrupted (eg. if you get a message saying "Not a valid JPEG"), then ExifTool can not be used to repair the image. Also, ExifTool may not be used like this to repair TIFF-based files or RAW files -- the risk of image corruption is too great because the image is stored in the same IFD as the metadata in these files.
exiftool -a my-image.jpgand the filter the output?
-aswitch, unfortunately no additional effect (same with