WriteToFile/FromFile causes a iOSImage to be rotated?

I was having wild fluctuations in the quality of my photos when using the Jason’s function to convert an image to a memory block on IOS. Turns out there is a compression parameter that was not included in the original function. I made the below modifications and it cleaned up the photos coming out of the routine.

[code]Declare function UIImageJPEGRepresentation lib UIKitLib (obj_id as ptr,compressionQuality As CGFloat) as ptr
dim d as new Foundation.NSData(UIImageJPEGRepresentation(image.Handle,.75))

dim mb as Xojo.Core.MemoryBlock
mb = d.DataMb

return mb
[/code]

compressionQuality

The quality of the resulting JPEG image, expressed as a value from 0.0 to 1.0. The value 0.0 represents the maximum compression (or lowest quality) while the value 1.0 represents the least compression (or best quality). 

Here is a link to Apple’s docs on this function where I found the compressionQuality parameter.
https://developer.apple.com/documentation/uikit/1624115-uiimagejpegrepresentation?language=objc

Awesome find @Steve Koger , and thanks for sharing here.

When you were looking into this, I don’t suppose you came across any explanation of what the default compressionQuality would have been if this parameter wasn’t supplied? Some of my users complain about “blurry” images, though most don’t, and so this could be a solution. But now I need to work out what value to send. I read on SO that a value of 1 can result in larger file sizes.

@Jason Tait I was getting random picture quality. I would have some that were good and others that were very poor. That’s why I dug deeper into it. I went with .75 as you can see in my example. All pictures now appear to be the same quality.