IEcapt is a command-line web browser that outputs screenshots

Sometimes you need to capture a web page in PNG or JPG format. And if you need to do that, it probably helps to be able to do it in an automated fashion, like by a script.

That’s IEcapt‘s purpose in life. IEcapt renders web pages using the Internet Explorer engine, then outputs it as a graphics file. Uses include e-mailing a dashboard to someone or capturing steps when technical writing. Sure, you can use a tool like Snagit or Greenshot, but IEcapt is free and can be automated.

If you need IEcapt, you probably already know it.

The ultimate command-line ZIP utility

I accidentally find Ken Silverman’s utility page from time to time and can never find it again when I want it, so if you need the ultimate command-line ZIP utility (KZIP), or the ultimate PNG optimizer (PNGOUT), to squeeze just as many bytes as possible out of your recompressed archives or your images while maintaining 100% compatibility, save this link. You’ll thank me later when you need it badly, like when you’re e-mailing an archive and it’s a few dozen bytes larger than your e-mail system allows.

Also check out his clever ZIPMIX utility.

What makes his approach to ZIP archiving special is that he emphasizes file size over speed. His software is built to take a few extra seconds to save a few bytes, if it’s possible to do so. Mainstream Zip/Unzip programs will still decompress his archives just fine; they just won’t match it for compression ratio most of the time. And in the rare event that they do, his ZIPMIX utility will take advantage of that. Just zip up the same files with both programs, then run ZIPMIX on the two archives. So Ken Silverman’s utilities win even when he loses.

I first noticed this phenomenon when using Info-Zip, when I found its -9 option produced smaller archives than PKzip’s -max option. The first thing I did was make sure PKzip could uncompress the Info-Zip archive I’d created. It did, so I never used PKzip to create an archive again. And every once in a while I find another tool that does better than the last best one I found. Right now Ken Silverman’s utilities are it.

I have an unusual appreciation of smaller archives. That’s because I’m old enough to have downloaded files over a 300-baud modem (but also young enough to remember having done so). Ken Silverman practices a lost art, and maybe there aren’t a lot of people left who appreciate that, but I still do.

Another easy Apache tweak

I ran my site through Google Page Speed on Tuesday, and scored a surprising 88 out of 100–higher than I expected. Getting above 90 is going to take some optimizations on files that WordPress updates may change, so I’m hesitant to do that, but one thing it told me to do was to cache more aggressively. That’s pretty easy, as it turns out, and I could definitely feel a difference afterward.

Here’s the trick. Read more

A fast way to turn lots of images into an Adobe Acrobat PDF file

I have a collection of magazine scans that, inconveniently, came as a series of JPG images rather than as PDFs that are more conducive to reading. I wanted PDFs, so I found a way to turn lots of images into an Adobe Acrobat PDF file.

Building the PDF manually took a good 30 minutes per issue, so I wanted a faster way. Using command-line tools, I was able to convert the entire collection (about 40 issues) in less than 30 minutes. Read more

A good tool for salvaging really bad photographs

I’ve been playing around with the perspective correction feature in Gimp 2.0, and while it’s invaluable, I’ve noticed that it really has a tendency to blur up a picture.

You can reduce this some by not editing JPEGs–it’s always best to convert JPEGs into PNG or TIFF format before editing anyway–but it only reduces the problem. And Gimp’s sharpen tool leaves a lot to be desired.

Enter SharpControl.There’s something of a tutorial available online. To be honest, I really don’t know what most of the things he’s saying mean. What I do know is that I can just load an image into it, take the defaults, and get a better-looking image than with any other program I’ve ever used. And if I fumble around a bit, sometimes I can get lucky and improve it even more.

Hey, I was trained as a writer. I had to stay after class one day to get what little Photoshop training I did get.

The program only speaks TIFF or JPEG, so you’ll have to convert to TIFFs if you decide to load into the program from files. The alternative is to paste the contents of the clipboard into the program, manipulate the image, then copy it back to the clipboard and paste into your imaging program.

It’s a free download, so if you’re playing with fuzzy images, go download it now.

More tips for playing with toy trains

As you can probably guess from the length of time between postings, the Lionel has proven to be quite the distraction. A welcome one, but definitely a distraction.
I’ve picked up a few tricks along the way.

Clean old plastic buildings quickly. My buildings had accumulated a decade or so of dust and grime sitting in a box, and they probably weren’t clean when they were boxed either. The solution? Put a dab of hand soap and a small amount of laundry detergent in a bucket, then fill it with warm water. Just put in enough soap and detergent to make some suds. Disassemble the buildings and drop them in. Let them soak for a few minutes, then scrub with a toothbrush. They’ll look almost new. Note: Don’t do this if they have decals, or if you deliberately weathered the buildings. If you don’t know what weathering means, then go get your bucket.

Cleaning severely rusted track. To clean severely rusted track, give it a thrice-over with a drill’s metal brush attachment. It’ll mark the track up badly, but it’ll clean it up fairly nicely and may allow a dysfunctional train to run again. Don’t worry about ruining a prized collectible; used Lionel track sells for 25-50 cents a section at a hobby shop. This also means you shouldn’t put a lot of time and effort into salvaging rusty track–especially considering the new stuff sells for a dollar.

Lubricate your cars’ wheels for smoother operation. Unlike the engine, WD-40 is fine for this. Put a small quantity of oil into a bottlecap, then use a toothpick to apply it anywhere that the axles come in contact with other parts of the car. After doing this, your train will run more quietly and smoother, and your locomotives will be able to pull approximately 30% more weight, so you can feel free to add another car or two.

Buildings on the cheap for the nether regions of your layout. If you have some kind of structured drawing program (Adobe Illustrator, KDE Kontour, Macromedia Freehand, or even something like Visio) you can draw the basic shapes of buildings, print them out on heavy card stock, and cut them up and glue them together. Get started by taking measurements from an existing building and use that as a guide to help you learn the height of a door, window, and floor. Export the file to some kind of raster format (JPG or PNG) prior to printing and use GIMP or Photoshop to add textures if your drawing program doesn’t support it. For added realism, cut out the windows and glue in pieces of transparent plastic (kitchen plastic wrap is fine but cutouts from clear plastic bags are nicer). It doesn’t take any longer than assembling and painting a plastic model, the results are surprisingly convincing–the only advantage plastic offers is more realistic texture–and you’ll never beat the price. And if something happens to the building, you can always print out and reassemble another one.

Polystyrene sheets for scratchbuilding plastic models on the cheap. Once you’ve built some paper models and want to move up to building plastic buildings from scratch, you can pay $7 for a small sheet of polystyrene at a hobby shop, or you can buy 88-cent Beware of Dog signs from the nearest hardware or discount store. It’s the same stuff, only bigger and printed on one side. Put the printed side on the inside of the model and cover it with paper if you want to keep your secret safe. If you live near a big city, I’ve heard that plastic distributors sell big 4’x8′ sheets of polystyrene for about $7. A square foot of material makes for a good-sized building, so a 4×8 sheet will probably yield more than 30 buildings.

Optimizing Web graphics

Gatermann told me about a piece of freeware he found on one of my favorite sites, tinyapps.org, called JPG Cleaner. It strips out the thumbnails and other metadata that editing programs and digital cameras put in your graphics that isn’t necessary for your Web browser to render them. Sometimes it saves you 20K, and sometimes it saves you 16 bytes. Still, it’s worth doing, because more often than not it saves you something halfway significant.
That’s great but I don’t want to be tied to Windows, so I went looking for a similar Linux program. There isn’t much. All I was able to find was a command-line program, written in 1996, called jpegoptim. I downloaded the source, but didn’t have the headers to compile it. I went digging and found that someone built an RPM for it back in 1997, but Red Hat never officially adopted it. I guess it’s just too special-purpose. The RPM is floating around, I found it on a Japanese site. If that ever goes away, just do a Google search for jpegoptim-1.1-0.i386.rpm.

I used the Debian utility alien to convert the RPM to a Debian package. It’s just a 12K binary, so there’s nothing to installing it. So if you prefer SuSE or TurboLinux or Mandrake or Caldera, it’ll install just fine for you. And Debian users can convert it, no problem.

Jpegoptim actually goes a step further than JPG Cleaner. Aside from discarding all that metadata in the header, its main claim is that it optimizes the Huffman tables that make up the image data itself, reducing the image in size without affecting its quality at all. The difference varies; I ran it on several megabytes’ worth of graphics, and found that on images that still had all those headers, it frequently shaved 20-35K from their size. On images that didn’t have all the extra baggage (including some that I’d optimized with JPG Cleaner), it reduced the file size by another 1.5-3 percent. That’s not a huge amount, but on a 3K image, that’s 40-50 bytes. On a Web page that has lots of small images, those bytes add up. Your modem-based users will notice it.

And Jpegoptim will also let you do the standard JPEG optimization, where you set the file quality to a numeric value between 1 and 100, the higher being the truest to the original. Some image editors don’t let you adjust the quality in a very fine-grained manner. I’ve found that a level of 70 is almost always perfectly acceptable.

So, to try to get something for nothing, change into an image directory and type this:

jpegoptim -t *

And the program will see what it can save you. Don’t worry if you get a negative number; if the “optimized” file ends up actually being bigger, it’ll discard the results.

To lower the quality and potentially save even more, do this:

jpegoptim -m70 -t *

And once again, it’ll tell you what it saves you. (The program always optimizes the Huffman tables, so there’s no need to do multiple steps.) Be sure to eyeball the results if you play with quality, and back up the originals.

Commercial programs that claim to do what these programs do cost anywhere from $50 to $100. This program may be obscure, but that’s criminal. Go get it and take advantage of it.

Also, don’t forget the general rule of file formats. GIF is the most backward-compatible, but it’s encumbered by patents and it’s limited to 256-color images. It’s good for line drawings and cartoons, because it’s a lossless format (it only compresses the data, it doesn’t change it).

PNG is the successor to GIF, sporting better compression and support for 24-color images. Like GIF, it’s lossless, so it’s good for line drawings, cartoons, and photographs that require every detail to be preserved. Unfortunately, not all browsers support PNG.

JPEG has the best compression, because it’s lossy. That means it looks for details that it can discard to make the image compress better. The problem with this is that when you edit JPEGs, especially if you convert them between formats, you’ll run into generation loss. Since JPEG is lossy, line drawings and cartoons generally look really bad in JPEG format. Photographs, which usually have a lot of subtle detail, survive JPEG’s onslaught much better. The advantage of JPEG is the file sizes are much smaller. But you should always examine a JPEG before putting it on the Web; blindly compressing your pictures with high compression settings can lead to hideous results. There’s not much point in squeezing an image down to 1.5K when the result is something no one wants to look at.

WordPress Appliance - Powered by TurnKey Linux