Resize images to be used on Live Tile – Windows Phone 7

Recently I added a live tile feature to one of my WP7 applications.
The app tile would show an image of a person, retrieved from a RSS feed.

Now because of the fact that the image is of a person, it’s not squared, but portrait. Meaning that the width of the image is shorter then the height. Also the image I need to display is larger than the windows live tile.
So when you just try to display this image without any modifications, you’ll get a weird result.

The original image

To fix this, you’ll need to resize the image.

First of all, download the image and map it to a BitmapImage object, you can just use an URI that points to the image on the web for this.

One note, before you can start manipulating the image, you’ll need to be sure it has been downloaded completely, so register to the ImageOpened event.

If needed you can also add code when there has ben a failure with downloading the image.

So when you are sure the image has been downloaded you can start manipulating it. Now an extra note here, there is a great library available on Codeplex ( and NuGet ) that adds many extension methods to the WriteableBitmap that are handy when dealing with any image manipulation. It’s called WriteableBitmapEx and can be found here ( ).

We need to target our image to a tile of 173 by 173 pixels, thus we need to find the aspect – ratio. To do this, we first need to determine what is the largest side of our image.

After this we can determin the destination width and height…

All we need to do now is performing the actual resize.

Now that you have ‘constructed’ your resized image, you’ll have to store it on the phone’s isolated storage before you can use it as a live tile image!

The live tile needs an URI to this saved image to work correctly. To get this done in one go you can use following method SaveTileBitmap, it will save the image and return you the correct URI.

So the last stop is using this method to get the URI and constructing a live tile…

You’ll need to give the image a name, but any name will do.

BUT when you do this, you’ll notice the image is still scaled to 173 px! This is something I didn’t except, but it seems the tile will always try to stretch to 173 by 173, thus miss forming our image.

Resized image – wrong!

To compensate we need to paste our resized image on a dummy 173 by 173 before storing it in the isolated store… In other words best to store a correct sized square image with the resized image pasted inside it at the correct location.

Because we know the width was the smallest, we need to center the image on the tile! So we will be merging the resized image starting not at position 0.0 but compensating for the smaller width!

Resized image – correct!