I tried to use CGImageSourceCreateWithURL method like below, but it seems both height and width are equal 0. Is there any other way to get webp image from url?

CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)imageUrl, NULL);
NSDictionary* imageHeader = (__bridge NSDictionary*) CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
NSLog(@"Image header %@",imageHeader);
NSLog(@"PixelHeight %@",[imageHeader objectForKey:@"PixelHeight"]);
NSNumber* height = [imageHeader objectForKey:@"PixelHeight"];
NSNumber* width = [imageHeader objectForKey:@"PixelWidth"];

1 Answers

0
Ryan Ou On

The webp format image is not supported in iOS. You can use URLSession to fetch image data, then use it to create NSImage with SDWebImage.