react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

`fmt: ImageFormat.WEBP` for `encodeToBytes` and `encodeToBase64` can't compress image very well

Open gyhyfj opened this issue 1 year ago • 4 comments

Description

Hope that fmt: ImageFormat.WEBP could reduce most size of normal png image, which couldn't.

gyhyfj avatar Jul 24 '24 03:07 gyhyfj

Could you provide more information what the issue seems to be?

wcandillon avatar Jul 25 '24 04:07 wcandillon

Could you provide more information what the issue seems to be?

For example, a .png image with a size of 3mb as input, when converted to webp by encodeToBytes, exported size will be about 2mb. But that same png image after converted by ffmpeg with same quality will be about 100kb.

gyhyfj avatar Jul 25 '24 12:07 gyhyfj

Is this a bug report or a feature request? If it is a bug, please provide me with a small reproducible example and what the expected result would be. If it is a feature request, please describe the behavior you would wish to see on this topic.

On Thu, Jul 25, 2024 at 2:09 PM gyhyfj @.***> wrote:

Could you provide more information what the issue seems to be?

For example, a .png image with a size of 3mb as input, when converted to webp by encodeToBytes, exported size will be about 2mb. But that same png image after converted by ffmpeg with same quality will be about 100kb.

— Reply to this email directly, view it on GitHub or unsubscribe. You are receiving this email because you commented on the thread.

Triage notifications on the go with GitHub Mobile for iOS or Android.

wcandillon avatar Jul 25 '24 12:07 wcandillon

It's a feature request

const input = await Skia.Data.fromURI(
  Image.resolveAssetSource(require('~/assets/test.png')).uri,
)
const image = Skia.Image.MakeImageFromEncoded(data)!
const output = image.encodeToBytes(ImageFormat.WEBP, 100)
// size of output is still large for saving and uploading, 
// hope to get a much smaller size with ImageFormat.WEBP

gyhyfj avatar Jul 26 '24 08:07 gyhyfj