webp

不用再看图片优化指南啦:v-img 介绍

我的梦境 提交于 2019-12-27 17:17:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 介绍 你是否早就看过所谓的万字长文,上面陈述了各种图片优化技巧,看完之后,你点赞、收藏,然后就下文了? 你是否早就听说了webp,但考虑到了兼容性,你又老老实实用回了jpg、png? 你是否在项目中拿到UI切的图片就用,使用 img 元素能显示就行,等项目上线了,才发现图片体积过大、刚打开首屏就发送了几十个图片请求,这时才想到对图片进行压缩、使用懒加载? 现在,使用 vue 技术栈的同学有福利啦。大家不需要再重复上述操作了,使用 v-img 组件,就可以解决上述烦恼。 你不需要掌握图片优化技巧、下载各种图片压缩工具,也不需要考虑 webp 的兼容性,也不用再去找懒加载的类库,这一切组件都帮你做了。 你继续使用 jpg、png,让组件帮你返回 webp,让图片加载更快,更节省流量,就是这样简单! 那么,这个组件到底怎么用呢?很简单,就是把代码里的 img 替换成 v-img 就可以了! 效果展示 说得这么神奇,到底效果如何,我们先来一睹为快。 懒加载 启用webp/使用阿里云OSS服务 启用webp/项目私有化部署 案例分析 下面来看一个项目在引入 v-img 前后的对比。 优化前 在没有使用 v-img 的时候,项目首页的加载情况是这样的: 如图所示, 首屏图片总体积为 947.1 KB,请求数量为 61 个。

CWAC Camera: why my SimpleCameraHost saveImage is so slow, am I doing something wrong?

末鹿安然 提交于 2019-12-25 03:55:41
问题 How to optimize this peace of code? It takes about a minute on saveImage method. class ObrolSimpleHost extends SimpleCameraHost { private final String[] SCAN_TYPES = {"image/webp"}; private Context context = null; public ObrolSimpleHost(Context _ctxt) { super(_ctxt); this.context = getActivity(); } @Override public void saveImage(PictureTransaction xact, Bitmap bitmap) { File photo = getPhotoPath(); if (photo.exists()) { photo.delete(); } try { FileOutputStream fos = new FileOutputStream

Failed to call dwebp in PHP

我与影子孤独终老i 提交于 2019-12-25 03:24:33
问题 I have installed webp package in my server and i want to use " dwebp " command in my PHP application. My command is simple, it is like dwebp "/full/path/test.webp" -o "/full/path/test.png" If i run it from SSH terminal, it is 100% succesful. But that command can't be run from PHP. I have tried to use system(), passthru(), exec(). All failed which means the PNG file is not created. However these commands succesfully called from PHP : touch. If i use this, the created file is under "apache"

encode bitmap to webp with libwebp on Android pre api 14 device

时间秒杀一切 提交于 2019-12-25 03:13:25
问题 I want to encode Bitmap to webp on Android 2.x device with libwebp . Below is my testing code public static int createWebPImage(Bitmap bitmap, String outFilePath) { Log.d(TAG, "create webp image"); ByteBuffer buffer = ByteBuffer.allocateDirect(BitmapCompat.getAllocationByteCount(bitmap)); bitmap.copyPixelsToBuffer(buffer); return nativeCreateWebPImage(buffer, bitmap.getWidth(), bitmap.getHeight(), outFilePath); } And the jni implementation is nativeCreateWebPImage(JNIEnv *env, jclass type,

encode bitmap to webp with libwebp on Android pre api 14 device

冷暖自知 提交于 2019-12-25 03:13:16
问题 I want to encode Bitmap to webp on Android 2.x device with libwebp . Below is my testing code public static int createWebPImage(Bitmap bitmap, String outFilePath) { Log.d(TAG, "create webp image"); ByteBuffer buffer = ByteBuffer.allocateDirect(BitmapCompat.getAllocationByteCount(bitmap)); bitmap.copyPixelsToBuffer(buffer); return nativeCreateWebPImage(buffer, bitmap.getWidth(), bitmap.getHeight(), outFilePath); } And the jni implementation is nativeCreateWebPImage(JNIEnv *env, jclass type,

Why can't I install Pillow on my mac? It gives some errors

心不动则不痛 提交于 2019-12-25 01:58:01
问题 here is the error from installing Pillow. I'm using OS X Mavericks. I tried installing Pillow through pip install.. _imaging.c:391:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] int temp = PyInt_AsLong(op); ~~~~ ^~~~~~~~~~~~~~~~ _imaging.c:397:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] int temp = PyInt_AsLong(op); ~~~~ ^~~~~~~~~~~~~~~~ _imaging.c:407:28: warning: implicit conversion loses

Android - java.lang.NoSuchFieldError: android.graphics.Bitmap$CompressFormat.WEBP

自作多情 提交于 2019-12-24 14:24:17
问题 I'm trying to use a very simple piece of code that has been supported since API 1. if (bitmap != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.WEBP, IMAGE_QUALITY, byteArrayOutputStream); byte[] bytes = byteArrayOutputStream.toByteArray(); result = Base64.encodeToString(bytes, Base64.DEFAULT); } somehow, bitmap.compress(Bitmap.CompressFormat.WEBP, IMAGE_QUALITY, byteArrayOutputStream); gives me that weird error: java

How to view webp format on ie11

霸气de小男生 提交于 2019-12-24 10:48:27
问题 Is there anyway to view webp image format on IE11 or can convert it to another format with javascript code on this browser? I tried "picture" element but seems like it cann't work like Chrome62 回答1: Webp works on all browsers with the webpjs polyfill (http://webpjs.appspot.com/) It uses flash for IE support (now you can use webp all the way back to IE6 as long as your browser supports flash). the swf file is missing from this page, but I found it here: https://github.com/obartra/webpjs 回答2:

Bitmap.CompressFormat.WEBP on Android API 19 alpha channel becomes black

断了今生、忘了曾经 提交于 2019-12-23 22:16:09
问题 I wrote a service that retrieves image from web (JPEG, PNG, ...), which I then, save to disk in webp format. I save the image using the following code: try (FileOutputStream fos = new FileOutputStream(imgFile)) { bitmap.compress(Bitmap.CompressFormat.WEBP, 100, fos); } catch (IOException e) { Log.e(TAG, "IOException writing file"); } catch (SecurityException e) { Log.e(TAG, "SecurityException writing file"); } I have not got any warnings. If the App runs in a device with API 22 or 23 the

On the fly clientside image to webp converter…but png's are not transparent

此生再无相见时 提交于 2019-12-23 10:07:10
问题 this is a working code to convert jpg or png to webp google's new image format that is in average 30-40% smaller than jpg's or png's 1.Open with Chrome 2.Set The quality 3.Drop an image inside the page 4.Wait (depends on the size .. try small images first) 5.Hover the image to see the size difference 6.To properly save it as webp just click on it Basycally chrome adde the possibility to add image/webp and the quality to the toDataURL function canvas.toDataURL('image/webp',quality(0-1)) The