Best way to display remote images?

You must Login before you can answer or comment on any questions.

I have a tableview of rows with an imageview on the left with a profile picture. Some pictures are portrait and some are landscape. Since the images are remote I do not have the width/height to calculate and resize/crop using the hack here (http://developer.appcelerator.com/question/125743/a-hack-for-cropping-images)

If I just set the images to the imageview I get whitespace on the sides (if portrait) or on the top/bottom (if landscape) where I want the images to be square.

Are there any recommended solutions that I am unaware of?

Here are my current options

-- Change imageview to view and stretch width and height to 100% (would look pretty crappy).

-- Download remote image to device, convert to blob, get width and height, use crop hack. (takes forever if you have more than a few images).

-- Crop server side (last resort, havent messed with this yet).

Are there any other options or am I missing something? Thanks for your time!

1 Answer

Accepted Answer

How are they added to the server? I have a function somewhere (PHP) that could take an uploaded image and get the height and width. I would then just store that in the database with the url, and do an if/else in my code to set the dimensions

— answered 8 months ago by Josh Lewis
answer permalink
1 Comment
  • I am uploading them to a .net server from the mobile app.

    So I can get the image height and width values on the server when they are uploaded, store them in db and then when I call the web service get the image along with the width and height. Then I would only have to call a resize function to get the new dimensions (with correct aspect ratio) for the smaller image I want to display.

    Sounds like the best option to me, thanks!

    — commented 8 months ago by andrew royce

Your Answer

Think you can help? Login to answer this question!