technical


17
Jul 10

An easy hack to sharpen images on iPhone 4

I recently released my first web app ported to the iPhone and Android devices. Only a couple days after deploying it, I found out about the increased DPI on the new iPhones.

Once I got my own iPhone 4 to test with, I noticed a huge problem with my web app. The images all looked pixelated against the beautiful text on the display. Not wanting to redo the CSS and header to define a larger viewport, I started to look for better solutions.

I decided to put larger images into the page than the tags were coded for. This way, the images would be resized smaller for the iPhone gen 1, 2, and 3. But for the iPhone 4, it would “zoom” the image to native resolution.

  1. Figure out the ratio that you need to increase all your images by.  This is the formula that I used… (960 / (viewport width)) * (image dimension).  My viewport was set to 320px and my image was 280px, so my equation looked like this:  (960/320)*280.  So, I created new images that were 840px wide.
  2. Since I already had my image tags defined with the appropriate height and width, I just saved the larger images as the same file names.
  3. Success.

This turned out really great, the iPhone does a fantastic job at scaling images, so it looks great on the older iPhones and looks fantastic on the new ones.  Check out the demo.

How to find the viewport on your web app.

<meta name=”viewport” content=”user-scalable=no, width=320” />

If you are using “device-width” as the viewport width, assume 320.
<meta name=”viewport” content=”user-scalable=no, width=device-width” />

A CSS based alternative solution

The folks at sitepoint suggest a CSS alternative that I believe is probably better if you are still in the development phase of your project.  Razor-sharp Images in Mobile Safari on iPhone 4

The only flaw I see in their solution is formula that they use to calculate image size.  Their double the size method does not accommodate for horizontal mode on the phones.

Old iPhone, before hack

Old iPhone, after hack

iPhone 4, before hack

iPhone 4, after hack


29
Mar 10

New Google easter egg

So, I am pretty much the worst speller ever. As such, I am always using google as a spell checker. Anyhow, today I was uncertain of the spelling of “recursion”. So, I googled it.

For those who do not know that recursion is… A recursive function or a subroutine is one that calls itself.

Recursion at Google

Let me google that for you.

Heck yeah, I love geek humor.

Cheers,
Jonathan


28
Feb 10

Three interesting definitions of programming


15
Jan 10

New form of CAPTCHA

I stumbled upon this tonight.  Seems like it would be a good way of verify humans.  The only problem is having the processing power to generate new ones every time a user views your form.  I’m afraid this will not be practical for many years.  But still, pretty cool

>


14
Oct 09

New platform for open data

Factual is a new web application that facilitates the open contributing of data on the internet.  Think of it as wikipedia for databases.  I’m pretty stoked.  I’m not sure if this experiment will turn out to be a winner or not.  But, I sure hope they make it.

The data stored in it is very much open ended.  For example here is a database of one of my favorite things, beer. Go ahead, edit the data. Add whatever details you you want.