diff --git a/iOS-WebP/UIImage+WebP.m b/iOS-WebP/UIImage+WebP.m index 2b6165f..61a26b8 100644 --- a/iOS-WebP/UIImage+WebP.m +++ b/iOS-WebP/UIImage+WebP.m @@ -159,7 +159,7 @@ + (UIImage *)imageWithWebPData:(NSData *)imgData error:(NSError **)error // Construct UIImage from the decoded RGBA value array uint8_t *data = WebPDecodeRGBA([imgData bytes], [imgData length], &width, &height); - CGDataProviderRef provider = CGDataProviderCreateWithData(config, data, config->options.scaled_width * config->options.scaled_height * 4, free_image_data); + CGDataProviderRef provider = CGDataProviderCreateWithData(config, data, (config->options.scaled_width || width) * (config->options.scaled_height || height) * 4, free_image_data); CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault |kCGImageAlphaLast;