Header Partially Corrupt 0xff 0x00, can we do basic convert to fix header

Started by joe.king.cool, February 07, 2022, 10:34:21 AM

Previous topic - Next topic

joe.king.cool

Hello all!

I ran a program called badpeggy. it checks photos for corruption. the photos open fine but would like for it to not show up in scans. some have suggest to open it and resave as jpg, then the header will be recreated. im not sure if im using the correct terminology.

is there a command that converts a jpg to a jpg without quality loss?

i attached a screenshot of the badpeggy app, and the app i created to change dates of jpgs and rename.


StarGeek

You would want to try a program that uses the jpegtran code.  Either the original command line tool or some other program that uses it.  It's normally used to losslessly rotate jpg images, but part of it's operations is to optimize the Huffman coding layer, which won't rotate the image.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

joe.king.cool

hmmm, im a noob for sure :) 

basically the images i have open and look fine, but (plex media app) scans and says they are corrupt to some degree. then i found a program called bagpeggy that finds files that are corrupt to some degree.

if i open in paint and save new, the scan dont show the files in the list of corrupted jpgs. seems easy but tedious. especially since paint dont have much of a command line.

so then i found JPEGsnoop, which seems like it can do allot with corrupt files and even recover really bad ones, but a little over my head at the moment.

was hoping for a command that open and resaves the image, and hopfully fixing the header issue, like in paint.

im goin to look into jpegtran code \ Huffman coding layer.

cross your fingers :)

StarGeek

Quote from: joe.king.cool on February 07, 2022, 11:46:11 AM
if i open in paint and save new, the scan dont show the files in the list of corrupted jpgs. seems easy but tedious. especially since paint dont have much of a command line.

This is a destructive recompress of the file, which leads to Needs More Jpeg.

Quotewas hoping for a command that open and resaves the image, and hopfully fixing the header issue, like in paint.

If you're on Windows, try Irfanview with the JPG_TRANSFORM Lossless plugin.

Go to the directory and open one of the files in Irfanview
Hit T or go to File Menu -> Thumbnails  This will open the irfanview thumbnail window.
Select images to process or hit control+A for all
While thumbnail window is active, Hit Shift+J or go to File Menu -> JPG Lossless Operations -> Lossless Rotation (Dialog)
The dialog window will open, these are my recommended settings

Hit Start.
Irfanview will try and process and optimize all the select jpegs.  This will also decrease the files size a few KB with no loss of image quality.

I can't guarantee that irfanview will fix the images, but this is what I would attempt to do.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

joe.king.cool

i found this based off your suggestions earlier, with a few tweaks. although i have to drop the jpg on the batch file. it does solve my current issue with corupt headers. -- although i cant figure out how to pipe a folder location of the jpgs and make it do for all jpgs in folder. i need to do this via command line, cause im adding to my app to auto fix. 

forfiles /s /m *.jpg /c "cmd /c jpegtran.exe -rotate 90 @FILE @FILE"
forfiles /s /m *.jpg /c "cmd /c jpegtran.exe -rotate 270 @FILE @FILE"
pause


StarGeek

No need to rotate twice, just use the -optimize option.  I would also suggest the -copy all option.  See Jpegtran Man page.

I can't really help with the batch files stuff, though.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

joe.king.cool

i just pieced this together before i seen your post. its a 1 liner in windows. i just need to replace user directorys with variables, then ill add to my app. if you would like to test my app i can post a link when im done testing?


cd "C:\Users\user\Desktop\test\" && forfiles /s /m *.jpg /c "cmd /c @\"C:\Users\user\Desktop\GMC_Photo_Date _Namer\jpegtran.exe\" -copy none -optimize -outfile @file @file"