Hello I have the following function to save a jpg image with a scale factor
- (UIImage*) pixelBufferToUIImage:(CVPixelBufferRef) pixelBuffer
{
CIImage *ciImage = [CIImage imageWithCVPixelBuffer:pixelBuffer];
CIContext *temporaryContext = [CIContext contextWithOptions:nil];
CGImageRef videoImage = [temporaryContext
createCGImage:ciImage
fromRect:CGRectMake(0, 0,
CVPixelBufferGetWidth(pixelBuffer),
CVPixelBufferGetHeight(pixelBuffer))];
UIImage *uiImage = [UIImage imageWithCGImage:videoImage scale:(1/scale_factor) orientation:UIImageOrientationUp];
CGImageRelease(videoImage);
return uiImage;
}
I call this method like so,
NSData* image = UIImageJPEGRepresentation([self pixelBufferToUIImage:frame.capturedImage], 0.8);
[image writeToFile:[self getFilePathWith:folderName and:@"image.jpg"] atomically:NO];
If I call the save with a scale_factor = 1.0f
which is the original resolution I get a 1280x720
image
However, I want to half the image size. I tried setting scale_factor = 0.5f and 2.0f
Both did not work and I get the jpg's size as 1280x720
Could anyone point out my mistake here?