Giter VIP home page Giter VIP logo

kingfisherwebp's Introduction

KingfisherWebP

CI Status Version License Platform

Description

KingfisherWebP is an extension of the popular library Kingfisher, providing an ImageProcessor and CacheSerializer for you to conveniently handle the WebP format.

The library works seamlessly with Kingfisher. To display the webp images from network, simply add WebPProcessor and WebPSerializer to your KingfisherOptionsInfo:

let url = URL(string: "url_of_your_webp_image")
imageView.kf.setImage(with: url, options: [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)])

For convenience, you may set it as a global default option to all KingfisherManager related methods:

// somewhere after your application launches...

KingfisherManager.shared.defaultOptions += [
  .processor(WebPProcessor.default),
  .cacheSerializer(WebPSerializer.default)
]

// You can now use webp in Kingfisher like any other format
imageView.kf.setImage(with: url)

Some image servers may expect the "Accept" header to include "image/webp". You can include this header to all Kingfisher requests by doing:

let modifier = AnyModifier { request in
    var req = request
    req.addValue("image/webp */*", forHTTPHeaderField: "Accept")
    return req
}

KingfisherManager.shared.defaultOptions += [
    .requestModifier(modifier),
    // ... other options
]

If the image data is not in webp format, the default processor and serializer in Kingfisher will be used.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 12 or above

Installation

CocoaPods

KingfisherWebP is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "KingfisherWebP"

Swift Package Manager

From Xcode 11, you can use Swift Package Manager to add KingfisherWebP to your project. The "package repository url" of KingfisherWebP is https://github.com/yeatse/KingfisherWebP.git.

SPM screenshot

Carthage

You can also add KingfisherWebP using Carthage. Note that KingfisherWebP is built on top of libwebp project, so in your Cartfile you should add libwebp dependency as well:

github "yeatse/KingfisherWebP" ~> 1.4.0
github "onevcat/Kingfisher" ~> 7.0.0
github "SDWebImage/libwebp-Xcode" ~> 1.1.0

Author

Yang Chao, [email protected]

License

KingfisherWebP is available under the MIT license. See the LICENSE file for more info.

kingfisherwebp's People

Contributors

conversun avatar crazyfanfan avatar danielebogo avatar dinsen avatar guilhermearaujo avatar kukushi avatar shaharhd avatar wangshuaiguo avatar yeatse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kingfisherwebp's Issues

can webp resource animate?

i find an issue #13 which you had supported animated webp, i try to fetch a resource webp image from server, but it didn't work, i don't know whether my usage is wrong? i paste some code in here.

// set global default options for Kingfisher
KingfisherManager.shared.defaultOptions = [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)]

then , in somewhere

imageView.kf.setImage(with: URL(string: url))

need some other configurations?

give a resource for test

https://p.upyun.com/demo/webp/webp/animated-gif-0.webp

thanks

Can i cache webp image format

Hi everyone,
I have successfully to load webp image from url. Could you have me to write some to used to cache webp image?
Thanks!

Can't build KingfisherWebP.framework with prebuilded libwebp.framework

I built libwebp framework via iosbuild.sh and imported using cocoapods as vendored framework to project. But i having problems with import paths in CGImage+WebP.m:
Compile error

Pods directory

If i change imports to:
#import "webp/demux.h" -> #import "webpdemux/demux.h"
#import "webp/mux.h" -> #import "webpmux/mux.h"
the error goes away, but i have problem with symbols for different archs (libwebp was build for all archs):

Undefined symbols error

Cocoapods use_modular_headers!

Hi.
I use Cocoapods to install, but I have an error while compiling.

This is my Podfile

use_modular_headers!

pod 'KingfisherWebP'

dd7285b1-b757-4b6b-8336-f9836d6b9205

AnimatedWebP is not working

Hi,

I am trying to animated webp but it's not working.
I can only see the first frame of the animated webp.

here's my code:
if let path = Bundle.main.path(forResource: "loader", ofType: "webp") {
let loader = AnimatedImageView()
loader.kf.setImage(with: URL(fileURLWithPath: path))
loader.startAnimating()
}

Note: KingfisherManager is set as a global default option in my AppDelegate.

I hope you can help me on this.

Thanks.

Crash on WebPImageCreateWithData

0 libsystem_platform.dylib
_platform_memmove + 76
1 KingfisherWebP
WebPImageCreateWithData + 160
2 KingfisherWebP
$s10Kingfisher0A7WrapperV0A4WebPSo7UIImageCRbzlE5image8webpData5scale14onlyFirstFrameAFSg10Foundation0G0V_12CoreGraphics7CGFloatVSbtFZAF_Tg5Tf4nnnd_n + 116
3 Kingfisher
$s10Kingfisher18ImageDataProcessorC9doProcess33_6119A2C527FFA834F85B326B80E79A62LLyyF + 604
4 Kingfisher
$s10Kingfisher18ImageDataProcessorC7processyyFyycACcfu_yycfu0
+ 20
5 Kingfisher
$s10Kingfisher13CallbackQueueO7executeyyyycFyyScMYccfU_TA + 20
6 Kingfisher
$sIegh_IeyBh_TRTm + 28
7 libdispatch.dylib
__dispatch_call_block_and_release + 32
8 libdispatch.dylib
__dispatch_client_callout + 20
9 libdispatch.dylib
__dispatch_lane_serial_drain + 748
10 libdispatch.dylib
__dispatch_lane_invoke + 380
11 libdispatch.dylib
__dispatch_root_queue_drain_deferred_wlh + 288
12 libdispatch.dylib
__dispatch_workloop_worker_thread + 404
13 libsystem_pthread.dylib
__pthread_wqthread + 288

crash

帮忙看个crash问题
9d3eUjzbi4

Dependency "KingfisherWebP" has no shared framework schemes

carthage update --no-build
carthage build --no-use-binaries KingfisherWebP
/tmp/static.xcconfig.SA6J0K
*** xcodebuild output can be found in /var/folders/74/lhqsynh976l12m_wrcmmg7880000gp/T/carthage-xcodebuild.lLFdWa.log
*** Skipped building KingfisherWebP due to the error:
Dependency "KingfisherWebP" has no shared framework schemes

If you believe this to be an error, please file an issue with the maintainers at https://github.com/yeatse/KingfisherWebP/issues/new

希望这个方法为public

static func image(webpData: Data, scale: CGFloat, onlyFirstFrame: Bool) -> Image?{...}
希望这个方法为public
public static func image(webpData: Data, scale: CGFloat, onlyFirstFrame: Bool) -> Image?{...}
可以在外部调用此方法进行webp的数据转图片操作了,毕竟这样更方便一些。
(Kingfisher 里类似方法是public的
public static func image(data: Data, scale: CGFloat, preloadAllAnimationData: Bool, onlyFirstFrame: Bool) -> Image? {...})

Swift package manager compiler errors

When importing into another package as dependency the following errors are returned when compiling:

Snímek obrazovky 2021-03-30 v 13 00 16

The swift package file looks like this:

let package = Package(
    name: "SomePackage",
    platforms: [
        .iOS(.v13)
    ],
    products: [
        // ...
    ],
    dependencies: [
        // ...
        .package(
            name: "Kingfisher",
            url: "https://github.com/onevcat/Kingfisher.git",
            "6.2.0"..<"7.0.0"
        ),
        .package(
            name: "KingfisherWebP",
            url: "https://github.com/Yeatse/KingfisherWebP.git",
            "1.3.0"..<"2.0.0"
        )
    ],
    targets: [
         .target(
            name: "SomePackage",
            dependencies: [
                 // ...
                "Kingfisher",
                "KingfisherWebP"
            ],
            resources: [.process("Resources")]
        )
    ]

Thank you

Memory Leak

I'm getting around 500MB of memory leak with this lib.
Screen Shot 2019-05-20 at 5 43 26 PM
Screen Shot 2019-05-20 at 5 43 12 PM

Memory Issue

After transfer png to webp format image,Our App memory increase too much like the attachments below,I don't know why and how to fix it,Please give me some advise
1 0
e
1 1
.

unusual animating

Hi, I have a problem, I try to using a webp image, but it plays very slowly. It happends when I using KingfisherWebP, it works fine on Chrome brower. So could you please take a look at it for me? Thanks:)

This WebP file:
test.webp.zip

has not support Kingfisher 6.0 ?

my Podfile:

 pod 'Kingfisher', '~> 6.0'
 pod 'KingfisherWebP'

pod install, log error

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "Kingfisher":
  In snapshot (Podfile.lock):
    Kingfisher (= 6.0.1, ~> 6.0)

  In Podfile:
    Kingfisher (~> 6.0)

    KingfisherWebP was resolved to 0.2.2, which depends on
      Kingfisher (~> 3.0)

Kingfisher SDK 7.9.0 had include privacy manifest, can KingfisherWebP update the dependent version?

hello

now the KingfisherWebP dependent the Kingfisher SDK version is 7.8.1,Kingfisher had give a update for adapter Apple privacy policy, version is 7.9.0:

onevcat/Kingfisher#2122

can KingfisherWebP update the dependent Kingfisher's version?

For more info, see:

Describing data use in privacy manifests | Apple Developer Documentation
Describing use of required reason API | Apple Developer Documentation
Get started with privacy manifests - WWDC23 - Videos - Apple Developer
Thanks!

load slow from disk cache

load slow from disk cache, set image completionHandler takes up to 10s to callback for a 5.5m webp animated image

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.