Giter Site home page Giter Site logo

WEBP图片加载失败 about ybimagebrowser HOT 3 OPEN

19aneng avatar 19aneng commented on June 27, 2024
WEBP图片加载失败

from ybimagebrowser.

Comments (3)

19aneng avatar 19aneng commented on June 27, 2024

能不能把YYImage加载换成SD加载,YY没人维护了,...

from ybimagebrowser.

YLbobo avatar YLbobo commented on June 27, 2024

现在解决了吗?

from ybimagebrowser.

fengshh93 avatar fengshh93 commented on June 27, 2024

在YBIBDefaultWebImageMediator.m头部导入#import "UIImage+MultiFormat.h"
把方法yb_downloadImageWithURL修改一下

  • (id)yb_downloadImageWithURL:(NSURL *)URL requestModifier:(nullable YBIBWebImageRequestModifierBlock)requestModifier progress:(nonnull YBIBWebImageProgressBlock)progress success:(nonnull YBIBWebImageSuccessBlock)success failed:(nonnull YBIBWebImageFailedBlock)failed {
    if (!URL) return nil;

    SDWebImageDownloadToken *token = [[SDWebImageDownloader sharedDownloader] downloadImageWithURL:URL options:SDWebImageDownloaderLowPriority progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
    if (progress) progress(receivedSize, expectedSize);
    } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {

      if (error) {
          if (failed) failed(error, finished);
      } else {
          SDImageFormat imgFType= [NSData sd_imageFormatForImageData:data];
          if (imgFType == SDImageFormatUndefined || imgFType == SDImageFormatWebP) {//处理webP图片不能显示的情况
              data = UIImageJPEGRepresentation(image, 1);
          }
          if (success) success(data, finished);
      }
    

    }];
    return token;

}

主要是webp图片请求成功,但是YBIBImageData 的loadURL_download方法转换失败导致
所以在yb_downloadImageWithURL添加了webP图片的处理
SDImageFormat imgFType= [NSData sd_imageFormatForImageData:data];
if (imgFType == SDImageFormatUndefined || imgFType == SDImageFormatWebP) {//处理webP图片不能显示的情况
data = UIImageJPEGRepresentation(image, 1);
}

from ybimagebrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.