Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Create a thumbnail of a picture


I created an iPhone app, where you can take pictures and put it on a map. I just want a pin. When you click on it, there should be a thumbnail picture.
Is there a way to shrink the picture with Titanium Mobile?


— asked October 16th 2010 by Felix Krause
  • iphone
  • map
  • picture
  • shrink
  • thumbnail

5 Answers

  • There is an undocumented function called imageAsThumbnail which you should check out. It scales and crops an image blob into a square thumbnail. To use it, convert an imageView to a blob. The function takes one parameter, which is the size of the square thumbnail you want to use.

    As far as using an image in the map annotation, I think you can only put the annotation in the left corner using the leftView property.

    // Convert your imageView into a blob
    var blob = imageView.toImage();
    // Turn blob into a square thumbnail
    blob = blob.imageAsThumbnail(64);
    // Create new imageView for thumbnail
    var thumbnailImageView = Ti.UI.createImageView({
       image: blob
    // Add image to annotation
        leftView: thumbnailImageView



    — answered December 28th 2010 by Brandon Jackson
    1 Comment
    • Hi Brandon
      Thanks for your great answer! I'll try it when I'm back from Holiday

      — commented December 29th 2010 by Felix Krause
  • This is a function I slapped together to resize an image. It returns an image that is the size you specified when you call the function.

    function resize_image(imagePath, height, width) {
      height = height || 64;
      width = width || 64;
      var imageView = Ti.UI.createImageView({
        image: imagePath,
        width: width,
        height: height
      return imageView.toImage();
    — answered October 16th 2010 by John McKnight
    • Hi
      Thanks for your code, but I only see this picture, when I resize the image: klick
      Do you know why I see that?

      — commented October 17th 2010 by Felix Krause
    • That usually shows up when the image cannot be loaded from a remote source. Do you have a piece of code I can see?

      — commented October 18th 2010 by John McKnight
    • Hi John, do you know if it is possible to do a Crop as well?

      — commented December 28th 2010 by Antonio Silveira
  • imageAsThumbnail() works well, but has anybody notice that it adds a white bolder around the thumbnail? For example, if I do imageAsThumbnail(192), the resulting thumbnail is 194x194 and there is a one pixel white bolder around the image

    — answered November 2nd 2011 by Alan Chen
  • There is a 1 pixel boarder by default - see the documentation for imageAsThumbnail:


    You should be able to set the borderSize to 0 to remove the border.

    — answered December 20th 2011 by Laurence Kirchmeier
  • can image thumnail be changed to any size you want. i think so .

    — answered April 24th 2013 by carolinenew forwefd
    1 Comment
    • we are dealing with JS not VB.NET

      — commented May 9th 2013 by Akshay Taru
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.