Converting ios webp to jpg and ioswebpjpg

Source: Internet
Author: User
Tags webp webp to jpg

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.