January 12, 2007

Adventures in a $60, 1-star, San Francisco Hotel

I’m staying at the “San Franciscan San Francisco” aka “The Olympic.” I can’t tell what this place is supposed to be called because the outside says “The Olympic” and some places on the internet call it “The San Franciscan” but at least I managed to find it with “It’s uh… on Mason St.” Among some of it’s key features:

  • $60/night
  • Private bathroom
  • TV (no cable, only antenna)
  • Free breakfast
  • Free wireless internet

*AND* there’s a bonus feature I didn’t see in any reviews: I can hear the war protest right from my room!

I didn’t expect much from this hotel. I mean, it only has 1 star, so how good could it be? I’m fairly impressed with the place though. It’s on the edge of the Tenderloin (bad neighborhood), but it’s only a block from Market (main area of downtown), so there’s no shortage of common folk to stave off the drug dealers and deranged wanderers. If you can’t afford anything else… well I guess you wouldn’t have a choice in that case. Let’s try again: if you’re trying to save money, I can see no reason not to pick this place. It’s got a great location, a great price, and the rooms aren’t half bad.

http://www.olympichotelsf.com/ - Hotel website.

January 11, 2007

ORD to LAX to SFO

“Enjoy your flight to Los Angeles!” Such friendliness is never expected given so many horror stories of security screening personnel and their strict requirements for entry.

Thou shalt restrict all containers of liquids to those which singularly hold no more than 3 ounces and together, within their respective containers, comprise no more than the volume of one quart-sized clear plastic ziplock bag. Your skin may be dry, but terrorists can make bombs out of your 20oz bottle of lotion so you’ll have to give it up for the greater good.

I saw a bottle of Bacardi discarded under the x-ray scanner. The cure for fear is removing that which cures fear for the fear that it might be something else. How does the old adage go? Alcohol is the cause of, and solution to, all of life’s problems. Given that, I hope someone gets to enjoy that bottle. Even if it didn’t solve any problems for the person that bought it, who’s now on the plane, and down $30. So much for bringing a security blanket.

Through the security checkpoint and on to the G/H wing I’ve come to know so well. A new wall-sized touch-screen interface greets me as G splits to the left and H to the right. A man stands close to it, as if he weren’t sure whether it was serious about the message “Touch me for weather.” Many people go their whole lives without encountering such a request. Mine was H-8 so I continued to the right and past an ATM. I should get money, I thought. Only by then I was halfway to my gate. I knew I had 2 dollars in my pocket so I veered to the Starbucks on the left side of the hall. Only 4 people in line? At a Starbucks? I can’t resist. I waited it out and got a “Tall” coffee, which, opposed to the tallest size, Venti, is actually a word, though not one I would use to describe the smallest of coffees. Oh well, people manage to adapt to their surroundings. And Starbucks manages to surround people very well. After that, I got hungry. Starbucks made me hungry.. but $2 meant I could only afford 1 of the cheapest thing on the menu. I left with my coffee, now empty of money (a 25 cent tip for a coffee isn’t too much, is it?) and decided to head back to the ATM to fill up my pockets. Then I headed to the food court, with a photo album of my three uncle Jacksons (they’re triplets). I noticed the regular food offerings, and the regular crowd in front of the McDonalds stand. The pizza joint was barren. By the time I got to the other side I had resolved to walk back to the Starbucks and get a muffin. What’s this? Lo and behold, directly in front of me was another Starbucks. Apparantely someone else had the same idea. This Starbucks was twice the size of the previous one, with a line on either side. And both lines had twice as many customers. Must be a better location. Are the two establishments competing? Is it appropriate to tell these customers about the other Starbucks just around the corner? I decided against it and got a blueberry muffin. I didn’t feel bad about spilling crumbs on the floor outside my gate.

January 8, 2007

HOWTO: ImageMagick and PDFs

ImageMagick is a handy tool for manipulating graphics from the command line. In essence, it’s a basic image editor and will do any standard resizing, color changing, cropping, rotating, etc. With a little cleverness and magick, though, this app is a powerhouse with many features Photoshop can only dream about. I’ve been using ImageMagick (and its variants for perl and php) for a few years and I’m still learning new things about it all the time. One of its coolest features is the ability to work with many different file formats, including PDFs. I’ve been dealing with some PDFs recently that I’d like to turn into sample images (ala “try before you buy”) and before today I had a hard time even loading the image into memory but now I know why.

When dealing with PDFs, ImageMagick rasterizes each page of the file, loading these rasterized images into memory as it works it’s way through the entire file. With a file that’s 5-10 pages, this isn’t a problem. With a file that’s over 500 pages, this is practically impossible. One way to get around the problem is to load only a small part of the PDF by specifying the pages after the filename. In PerlMagick (if I want to load the first page):

$image = new Image::Magick;
$image->Read(’thefile.pdf[0]‘);

This rasterizes the first page of the file without loading anything past that page. To write the image to disk (in a format that doesn’t require Acrobat Reader) I can use the following:

$image->Write(filename=>’page1.gif’);

If you’re following along on your own computer, you’ll now notice that the new image looks horrible. The quality is severely reduced from the original making most (if not all) text unreadable. This is a problem since PDFs typically contain a lot of text.

The quality is reduced because ImageMagick reads the image in at screen resolution (72 dpi). When the PDF is viewed on the screen by Acrobat Reader, the vector-based text has more information and can be anti-aliased to look decent even when zoomed out very far. When removing the vector information, the image loses all of that helpful data. One way to work around this is by setting the resolution (and in turn, how much of the vector information you’d like to retain) before loading the image.

$image->Set(density=>’300′);

This will set the resolution to 300 dpi. This is typical magazine resolution so it’s plenty for my purposes. Now, however, the resulting image is huge. To fix this, I’ll simply resize the image to a more web-friendly size. The following command will make the picture 500 pixels wide:

$image->Resize(’500′);

When resizing an image after loading it in at a high-resolution, ImageMagick is able to use the extra data to anti-alias the text, making it look almost as good as the original pdf.

Here are the new commands in order with the rest of the steps (and an extra one to free up the memory):

$image = new Image::Magick;
$image->Set(density => ‘300′);
$image->Read(’thefile.pdf[0]‘);
$image->Resize(’500′);
$image->Write(filename => ‘page1.gif’);
undef $image;

Now with a loop, it’s easy to step through each page in the document and convert it. In my program, I only want to use five pages to give someone a sample of the full document. I could use the first five, or jump through the document giving the user a look at the beginning, middle and end.

If you have any questions or notice any errors, let me know by leaving a comment below. Thanks for reading!