UIImage-Categories
UIImage-Categories copied to clipboard
Aspect fit scaling results in image one pixel too large
This bug occurs with the resizedImageWithContentMode method.
I am passing an image whose dimensions are reported to be 4877x3515. When I supply a bounds parameter of 1000x1000, the resultant image's size is 1001x721.
I believe the bug is on this line:
CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio);
It looks like the resultant width is 1000.0001. The resultant width and height should be MIN
ed with the bounds
parameter:
CGSize newSize = CGSizeMake(MIN(bounds.width, self.size.width * ratio), MIN(bounds.height, self.size.height * ratio));