skip to Main Content

This might not be the proper place to ask this since it seems the issue is with the actual image, but I’m hoping someone here has seen this issue before.

I am loading images from a server. First I take the photo, upload it from the server and then view it in a different part of the application. This is when I saw that the aspect ratio of any image I had just uploaded was way off. See image one below. Images that I had uploaded in the past did not have these issues. The difference is that I had to pull the previous images into photoshop to rotate them.

I got my node.js server to orient them for me but then when I load them up in the UIImageView they are squished and stretched. Viewing them in the browser or on my computer shows them as normal. Out of curiosity I opened one in photoshop, did not manipulate it at all and saved it out. When I uploaded it to my server and viewed it on the iPhone again it looked as it should. See the second image below.

Again all other images load just fine but the ones that did not go through Photoshop come out all wonky.

Any thoughts? Thanks in advance for your help.

enter image description here

enter image description here

EDIT : When viewing the photos in the browser they are also stretched when resized. When I click to view full size and then click again to view the scaled to fit the screen they look fine. Just wanted to throw some more info out there to see if anyone knows what’s up.

2

Answers


  1. Chosen as BEST ANSWER

    I'm not sure what the problem is exactly but I found a sort of solution.

    First off I tried it from a 4s to make sure it wasn't an issue with my phone and I got the same result. I found out that if I strip the exif data out of the image it seems to work just fine. What I ended up doing is using a package on my server, GraphicsMagic, and running the images through autoOrient. After this is done and saved out to disk the images load just fine in both the browser and on the iPhone. If anyone has any explanation of what would cause that, that would be great.

    Thanks!


  2. try this code,

        - (UIImage*)imageWithImage:(UIImage*)images
                  scaledToSize:(CGSize)newSize;
    {
        UIGraphicsBeginImageContext( newSize );
        [images drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
        UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return newImage;
    }
    

    and then set imageview imaeg this way

       imageView.image =  [self imageWithImage:mi.imageView.image scaledToSize:CGSizeMake(78, 78)];
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search