Testing to Verify That Photo Files Are Good
I had a bunch of JPGs in different folders. I wanted to convert them to PDFs. In the process of doing this, I found a way to verify that the JPGs were still of good quality. This post describes that method.I wanted to move the files in this case, but it would also work to just make copies of them and run through these steps on the copies.
I began by opening a DOS box, also known as a command window. I was using Windows 7, but substantially the same steps would work in other versions of Windows. The easiest way to open a DOS box was to have a context menu (i.e., right-click) option to open a command window in Windows Explorer. I had added that option using Ultimate Windows Tweaker (UWT). The option in question was in the Additional Tweaks section of UWT. This option added an "Open Command Window Here" context menu (i.e., right-click) option in Windows Explorer. If I hadn't planned on using command windows frequently, I could also have just gone to Windows 7's Start button > Run > cmd.
First, I assembled a list of files to be copied or moved. The command I typed for this purpose was this:
DIR "D:\Source Place\*.jpg" /a-d /s /b > D:\Dirlist.txt
with quotation marks, spaces, and everything else exactly as shown. (If a command is hard to read here, it can be made larger with Ctrl-+ (i.e., hold down the Ctrl key and hit the + key on the numeric keypad). You can also copy and paste it into a word processor or Notepad to make it more legible.) I would have needed to run this command again if I'd been searching for JPEGs as distinct from JPGs. This command gave me a list of JPGs that existed on my hard drive in a folder on drive D called Source Place, or in any subdirectories under that folder. The list was contained in a file called Dirlist.txt, located at the root of drive D. To see what command-line options (e.g., /a-d) were available, I could type, in a DOS box, the command with a /? after it. For example, I could get the parameters for using the DIR command by typing "DIR /?" (without quotation marks).
Once I had my list of the JPGs I wanted to test, I could move or copy them to another folder where I would be doing the testing. I created a folder called D:\TestJPGs for this purpose. To move the JPGs there, I opened the Dirlist.txt file in Microsoft Word, though any editor capable of recognizing the ends of lines of text would be able to do the job. (Using Word did require me to do the final editing in Notepad: I had Word set to insert smart quotation marks, and those would not run as commands, so the last step before running a batch command file created in Word was to copy it into Notepad and replace the Word-style quotation marks with plain-text Notepad-style quotation marks.) Using global search and replace in Word, I changed each line in Dirlist.txt to the following form:
MOVE "D:\Source Place\Subfolder A\photo.jpg" -y D:\TestJPGs
In other words, Dirlist.txt provided the list of files that could be converted into a list of commands. Quotation marks were not necessary around that destination name (i.e., D:\TestJPGs) because there were no spaces in that file or path name. Doing global changes to insert things at the beginning and ends of lines was easier with the knowledge that ^p was a common line-ending character in Word. It seemed necessary to use the Dirlist.txt step because the MOVE command did not offer a /s option. That is, I would have to explicitly identify JPG file locations and command them to be moved. Note that somewhat different options were available for the COPY command as distinct from the MOVE command.
Once I had all the JPGs in a single place, I could run a test on them. The test consisted of simply converting each JPG into a PDF file using the free Irfanview program. (If all the files to be tested were already in one place, of course, the foregoing MOVE or COPY options would not be necessary.) In Irfanview 4.28, the command to be used was File > Batch Conversion/Rename. There, the necessary steps were to select the files to be tested, click Add, designate an Output Directory, and then go to the Batch Conversion Settings area and indicate PDF output format, though probably other formats would work too -- taking care to click Options and adjust quality levels if you planned to keep the converted output files.
Then I clicked on the Start Batch button, there in Irfanview. When the conversion process was done, Irfanview gave me a list of messages regarding files that had converted successfully to PDF, along with some that had not. I sorted this list in Word and saved the ones that were in this format:
Error! Can't load: E:\JPGs\filename.jpg
I verified that neither Irfanview nor Windows Photo Viewer could view those files. My next step was to search for a JPG repair utility. This search led eventually to JPEGsnoop, which (after the assorted misleading websites I encountered along the way) was a refreshingly genuine freeware program of repute. I downloaded and tried it. JPEGsnoop (also apparently good on AVIs and other filetypes) turned out to be able to detect bad JPGs, thus simplifying much of what I was trying to do in this post. It wasn't perfect, though: it got hung up on a photo that Irfanview was able to open with no problem. It also created a separate .txt file per JPG, containing file information for each JPG it examined, which I didn't need right now, so I had to manually delete those. Another program of this type, ImageVerifier, whose webpage seemed to present a programmer who was doing a lot of thinking and experimenting about how to verify and preserve files with the use of a database scheme. After installing it, they told me that it would only evaluate 50 files unless I bought the paid version. So at this point, I wasn't sure these were better than the IrfanView approach (especially since I did ultimately want PDFs to replace the JPGs with).
Returning to the question of how to repair JPGs, I did encounter the occasional webpage on how to manually edit JPGs to fix them, but this was not something I was going to get into at this time. I didn't find any freeware for this purpose. I did find some shareware, but it didn't seem to be very highly rated, specifically All Media Fixer and DDR Digital Picture Recovery. Possibly PixRecovery was a superior alternative -- at a price of $149. At this point, I had to conclude that the world was still waiting for a good, free, automated JPG repair program.
2 comments:
Note the advice to make sure the Unicode plug-in is enabled in IrfanView. See http://en.irfanview-forum.de/vb/showthread.php?6309-Unable-to-open-jpg-file
Another post looks into some additional options. See http://raywoodcockslatest.blogspot.com/2011/04/repairing-damaged-jpgs.html
Post a Comment