0

Taking Image:

I'm taking the image using the code in this question: Scaling UIImage with a UIIImagePicker's CGAffineTransform and Saving to Parse SDK

Convert UIImage to NSData & Save

    _imageData = UIImageJPEGRepresentation(_image, .1);
    PFFile *imageFile = [PFFile fileWithName:@"image.png" data:_imageData];
    newMessage[@"image"] = imageFile;

Problem:

When I redownload the data, the UIImage appears squished. When I look at the image on my database, it seems like the height and width are reversed. Not sure why this is happening...

Community
  • 1
  • 1
Apollo
  • 8,874
  • 32
  • 104
  • 192

1 Answers1

0
NSData *imageData = UIImageJPEGRepresentation(yourImage, 1.0);
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];

    PFObject *userPhoto = [PFObject objectWithClassName:@"Photo"];
    [userPhoto setObject:imageFile forKey:@"image"];

    // Set the access control list to current user for security purposes
    userPhoto.ACL = [PFACL ACLWithUser:[PFUser currentUser]];

    [userPhoto setObject:user forKey:@"user"];

    [userPhoto saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (!error) {
            NSLog(@"sucess");
        }
        else{
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
        [[ConnectionManager sharedManager] removeload];
    }];
Sandeep Singh
  • 268
  • 1
  • 9