Lorsque je prends une photo en Le mode portrait, savedImage
est automatiquement pivoté lors du réglage sur UIImageView
.UIImage est automatiquement pivoté lorsqu'il est chargé à partir de Filemanager
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"ProfilePicture.png"];
[UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES];
UIImage *savedImage = [UIImage imageWithData:[NSData dataWithContentsOfFile:filePath]];
Mais quand j'utilise la méthode UIImageJPEGRepresentation: writeToFile: atomically:
, l'image résultat n'a aucun problème.
Quelqu'un peut-il s'il vous plaît expliquer pourquoi je n'ai pas obtenu l'image dans l'orientation correcte tout en utilisant UIImageJPEGRepresentation
& pas dans UIImagePNGRepresentation
.
NB: J'ai essayé
UIImage *imageToDisplay =
[UIImage imageWithCGImage:[originalImage CGImage]
scale:[originalImage scale]
orientation: UIImageOrientationUp];
pour sauver imageToDisplay
, mais ne fonctionne pas