I need to resize UIImage
proportionally by width, may be someone have a working code?
For ex.:
Input: Width: 900 Height: 675. Resize to width: 400 width
Result: Width: 400 Height: 300
Please help..
Check this blog post out. In particular, these two files:
Maybe this would work for you:
UIImage *image = [UIImage imageNamed:@"SomeImage-900x675"]; // SomeImage-900x675.png
CGFloat targetWidth = 400.0f;
CGFloat scaleFactor = targetWidth / image.size.width;
CGFloat targetHeight = image.size.height * scaleFactor;
CGSize targetSize = CGSizeMake(targetWidth, targetHeight);
UIImage *scaledImage = [image resizedImage:targetSize interpolationQuality:kCGInterpolationHigh];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With