Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28093

TiAPI: Add properties "uprightWidth" and "uprightHeight" to Ti.Blob


    • Story Points:


      When a Titanium Blob wraps an image, its "width" and "height" properties provide the "decoded" image's dimensions. Unfortunately, Android's native image loading APIs ignore a JPEG's EXIF orientation, meaning the image is loaded as-is (no rotation applied). While our ImageView and other APIs will correctly handle the EXIF orientation, the blob's "width" and "height" is for the unrotated image which makes it difficult to do manual layouts (ex: calculate letterbox scaling).

      Proposed Solution:
      Add the following properties to Titanium Blob:

      • uprightWidth
      • uprightHeight

      The above properties will return what the image width and height should be when a JPEG's EXIF orientation is applied onscreen. If the image is not a JPEG or the JPEG has no EXIF orientation, then these properties will return the same values as "width" and "height".

      And since iOS loads images in the upright positions, the above properties will always return the same values as "width" and "height".

      Developers need the image's actual width and height to do things like letterbox scaling. For example...

      var scale = Math.min(
      	Ti.UI.convertUnits(window.size.width, Ti.UI.UNIT_PX) / imageBlob.width,
      	Ti.UI.convertUnits(window.size.height, Ti.UI.UNIT_PX) / imageBlob.height);
      imageView.image = imageBlob;
      imageView.width = imageBlob.width * scale;
      imageView.height = imageBlob.height * scale;

      If the JPEG is loaded sideways (ie: its EXIF orientation is ignored), then the above will scale the image wrong.

      This is an interim solution. A better solution would be to completely refactor Titanium's image loading code and decode the image in the upright position (pre-rotated). This will be a huge undertaking that is best done in a major Titanium release version. But when we do this, Android's "uprightWidth" and "uprightHeight" properties will match "width" and "height" just like iOS.


          Issue Links



              • Assignee:
                jquick Joshua Quick
                jquick Joshua Quick
                Gary Mathews
                Samir Mohammed
              • Watchers:
                5 Start watching this issue


                • Created:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration