Converting ios webp to jpg and ioswebpjpg
In the process of project development, we encountered a problem: webp pictures. First, Let's explain what webp is. webp is a picture format developed by Google to speed up image loading. The image compression volume is only about 2/3 of the JPEG size. To put it simply, it saves space, especially for mobile apps.
The problem is that Apple's native does not support webp images, so we need third-party support. However, third parties on the Internet may need cocoapods, but they do not like it personally, therefore, I have integrated the required resources. In fact, some resource files can be used directly together, which makes my personal experience very convenient. I will share it with you here.
This is github address: https://github.com/YouZhiZheShiJingCheng/YZwebp
Directly put the downloaded file in the project, and then you need to put YZ. h or UIImage + WebP. import h to the pch file, and find the target of the Project> Build Setting-> Linking-> Other Linker Flags to-all_load,-force_load, or-ObjC. The usage is as follows:
UIImageView * imagev = [[UIImageView alloc] initWithFrame: CGRectMake (20, 20,200,200)];
The premise is that the 11108. webp image is in the project.
NSString * pathStr = [[NSBundle mainBundle] pathForResource: @ "11108. webp" ofType: nil];
Imagev. image = [UIImage imageWithWebP: pathStr];
[Self. view addSubview: imagev];
That's it. If you feel well written, just give it a compliment.