Thursday, January 12, 2006

Making the Connection

Morning weigh-in: 180#, 13% BF

So last night I was supposed to go to the gym, but blew it off when I realized I'd already eaten too much time, would get there too late to get in a good workout, so instead I played more with the computer(s) & read a little more from that book of medieval history. Dinner was the tuna & wilted greens over pasta.

What I was doing was, I'd noticed that a few of my photos in some of my original (ie non-flickr) galleries wouldn't display and wanted to fix them, but I couldn't remember which ones they were -- and I didn't want to search through all my photos one at a time, looking for the bad ones especially over a dialup line. So...

At first I thought maybe the JPG file didn't get copied properly when I first put it on my website (thus it would be empty), so I ssh'ed into the Super Dimension Fortress, ran something like this:

[me@sdf galleries]$ ls -l */photos/*.jpg | awk '$5==0 {print $9}'

This would have listed all my regular (ie non-thumbnail) photos, and displayed any that had zero length, but nothing showed up. OK, the files are probably not empty but corrupt, so I ran something like:

[me@sdf galleries]$ file */photos/*.jpg | awk '$2~/data/ {print $1}'

This goes through all my JPEG's, looks inside them to determine their data type, and display the ones that are just plain "data" rather than "JPEG." Bingo! I found four or five files that were corrupt, so for each of them I ran something like this on my home machine:

[me@local photos]$ djpeg foo.jpg | pnmscale 0.5 | cjpeg | ssh me@sdf 'cat - >foo.jpg'

This "decompresses" the JPEG file foo.jpg, runs it through a scaling program, "compresses" the output back to JPEG and sends that to ssh, which is set to write its input to foo.jpg on the other machine. Badda-bing, badda-bang, twenty minutes of thinking saved me hours of drudgery.

No comments: