seanooi / ios-webp Goto Github PK
View Code? Open in Web Editor NEWGoogle's WebP image format decoder and encoder for iOS
Home Page: http://seanooi.github.io/iOS-WebP/
License: MIT License
Google's WebP image format decoder and encoder for iOS
Home Page: http://seanooi.github.io/iOS-WebP/
License: MIT License
It would be really nice if this package could be installed using Carthage.
Picture size is 1242x18909, UIImage conversion WebP,result Zero bytes.
I met an strange question which is that I compressed an UIImage to WebP, but some colors lose, and I also try to use other quality and WEBP_PRESET but fianlly I find the problem is casued by ALPHA parameter. I tried use other numbers less than 1 all are correct. And I try to edit some source code:
if (alpha <= 1) {
image = [self webPImage:image withAlpha:alpha];
}
to enforce call webPImage:withAlpha
method first and will fix this problem. I don't why, so could you help to fix this issue?
THX
[Unknown process name] CGDataProviderCreateDirect: Invalid size = 0
[Unknown process name] CGImageCreate: invalid image provider: NULL.
[Unknown process name] CGDataProviderCreateDirect: Invalid size = 0
[Unknown process name] CGImageCreate: invalid image provider: NULL.
I have an app which imports pngs from the user's photolibray. I store these in a sub-folder hierarchy in my documents directory.
I was hoping that storing them in webP format would give me a significant savings. I rarely need to access these images but need them around for reference.
Basially, I want no-alpha lossless. Also of note are that these images are screenshots from an iPhone app, so graphical not photographic.
But my webP images end up less then %10 smaller, and often larger. I downloaded the free utility "PhotoConvert Lite" and it manages to output web that are 40% smaller. I assume it is respecting my lossless setting.
My code looks like this:
[UIImage imageToWebP:image quality:100 alpha:1
preset:WEBP_PRESET_DEFAULT
configBlock:^(WebPConfig* config)
{
config->lossless = 1;
config->image_hint = WEBP_HINT_GRAPH;
}
completionBlock:^(NSData* result)
{
// save file
} failureBlock:^(NSError* error)
I copy the code from the Demo. The webP image has changed its color.
my code :
NSData *webPData = [UIImage imageToWebP:tempImg quality:75.0f];
imageView.image = [UIImage imageWithWebPData:result];
when pod 'iOS-WebP' will download 0.4version, not 0.5, which has memory leak issue!!!
Please update
Is it just me or it does not work anymore on iOS 11.2 Beta? The imageRef
in:
CGImageRef imageRef = CGImageCreate(width, height, 8, 32, 4 * width, colorSpaceRef, bitmapInfo, provider, NULL, YES, renderingIntent);
always return nil.
I think this issue worth checking since it can potentially break everyone code when Apple officially release 11.2...
I'm trying your library, it works on simulator (32 and 64 bit) but it doesn't work on device. Your demo project crashes after about one second if is runned on device (ios 7.1 iphone 5)
The application crashes on CGSConvertAlphaByte
Any advices?
The Image's url is http://os.yesky.com/cmsimagelist/2007/131/8dz9mbqidnd3.jpg .
when I use this image for test.The image which was encoded to WebP by demo can't show.
Hello!
I'm having this error when I'm trying to decode my NSData:
App(568,0x3c88418c) malloc: *** error for object 0x312eac: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
I cant decode my image... :(
Hi I found the lib is bit slow and utilise more cpu when encode to WebP
Am i right..?
[This was posted as part of another topic, which was closed....not by me). So I moved it here
Here are two images, JPEG and webP. Notice the big color shift. The UIImage that's given to the JPEG and webP compressors is generated from a cocos2D openGL layer that gets rendered into a UIImage. I'm not sure if that's affecting the webP encoder, but as you can see, the color shift is noticeable. Again, If I decompress the JEPG and then recompress with webP, I have no problem--there is no color shift
How do I save the decoded WebP image to Gallery/Photos ?
@seanooi
您好!请问framework的代码可以开源的嘛?
Jack
malloc: *** error for object 0x70000021c7d0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
void WebPSafeFree(void* const ptr) {
if (ptr != NULL) {
Increment(&num_free_calls);
SubMem(ptr);
}
** free(ptr);
**
Crashing in last line.
let me know if anything else is required .
Xcode: 7.1.2
Sim: iPhone6S Plus
iOS: 9.2
Thanks in advance !
I tried to encode using libwebp-0.4.0 in this repo, but could not error out, to use libwebp-0.4.0 to encode.
Can't run the project, it says:
iOS-WebP/UIImage+WebP.m:10:9: 'WebP/decode.h' file not found
Have you been able to get this working with swift?
Images that are not in BGRA format don't work, you have hard-coded the encoder to:
WebPPictureImportRGBA(&pic, webPImageData, (int)webPBytesPerRow);
WebPPictureARGBToYUVA(&pic, WEBP_YUV420);
WebP.framework has build with Enable Bitcode = "No",When I have added this library with latest Xcode,throwing this error:
WebP.framework/WebP(libwebpdecode_la-webp.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64.
Can you provide latest library with ENABLE_BITCODE = YES
Can you please add 64bit arch to the webP framework
Thanks for you nice work
We want to use this framework with WatchOS2 but get an error for the framework file: file is universal (5 slices) but does not contain a(n) armv7k slice
I suddenly found, that there is some problem with alpha, when saving it to webp.
I changed your example to demonstrate it.
https://www.dropbox.com/s/bjww7ud4n7qhsgn/iOS-WebP-master-alpha.zip
because I am in the wall(built by the great PRC) ?how can I fix that .
[!] Error installing libwebp
[!] /usr/bin/git clone https://chromium.googlesource.com/webm/libwebp /var/folders/5v/nwy8rsn57gv54vswtjbx1_sr0000gn/T/d20180405-24822-1tunis3 --template= --single-branch --depth 1 --branch v0.5.0
Cloning into '/var/folders/5v/nwy8rsn57gv54vswtjbx1_sr0000gn/T/d20180405-24822-1tunis3'...
fatal: unable to access 'https://chromium.googlesource.com/webm/libwebp/': Failed to connect to chromium.googlesource.com port 443: Operation timed out
hi @seanooi ,
when i add header in bridge file but it show error file not found
If you profile the Demo app with the Leaks instrument, it shows a leak, in the line where it calls WebPEncode. I am using the latest release version of Xcode.
How to support WKWebView in iOS8?
In your asynchronous decoding methods (imageWithWebP:completionBlock:failureBlock: and imageToWebP:quality:alpha:preset:configBlock:completionBlock:failureBlock:), you create a local variable dispatch queue "toWebPQueue". What's the point of creating a local dispatch queue that is going to be used just once? Why not just use a global queue?
it's out of memory , when I change some images to webp .
dispatch_queue_t changeToWebp = dispatch_queue_create("changeToWebp", NULL);
dispatch_async(changeToWebp, ^{
NSData *data = [UIImage imageToWebP:img quality:75];
});
Hi,
Is it possible to convert this iOS-WebP library to use in Mac OS?
I would like to use this library to convert image to WebP format in Mac OS.
Thanks.
the CGDataProviderCreateWithData call uses a pointer to a WebPDecoderConfig struct on static memory for the info (first) parameter. The free_image_data callback is called after imageWithWebPData ends and the WebPDecoderConfig goes out of scope and becomes invalid. The callback attempts to release the invalid struct and crashes the application. This issue is addressed in https://github.com/imojiengineering/iOS-WebP/commit/aa4cffa97e586e6c28d9acfb6b13e64a621dc719.
ALAssetRepresentation *assetRep = [currentAsset defaultRepresentation];
CGImageRef imgRef = [assetRep fullResolutionImage];
UIImage *postImage = [UIImage imageWithCGImage:imgRef scale:assetRep.scale orientation:UIImageOrientationUp];
NSData *imageData = [UIImage imageToWebP:postImg quality:50.f];
then show this imageData in the app, the image Color is wrong. but if I convert native png or jpg to NSData ,it is right. I don't know why.
like this ,it is right.
UIImage *image = [UIImage imageNamed:@"xxx.png"];
NSData *imageData = [UIImage imageToWebP:image quality:50.f];
Hi,
I am having the same issue as #1 when installed via cocoapods:
$ pod install
[...]
Using iOS-WebP (0.4)
//
// UIImage+WebP.h
// iOS-WebP
//
// Created by Sean Ooi on 12/21/13.
// Copyright (c) 2013 Sean Ooi. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <WebP/decode.h>
=> 'WebP/decode.h' file not found
Regards,
UIImageView *currentImageView = xxx // this is a iOS webp image
// then:
UIImageWriteToSavedPhotosAlbum(currentImageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
{
// error is:
//There was a problem writing this asset because the write failed.
}
It does not look like v. 0.5 has made it into the cocoapods repository yet,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.