Shopify / react-native-skia

High-performance React Native Graphics using Skia
https://shopify.github.io/react-native-skia
MIT License
6.64k stars 420 forks source link

Sampling issue with WebP #2507

Open wcandillon opened 5 days ago

wcandillon commented 5 days ago

Discussed in https://github.com/Shopify/react-native-skia/discussions/2449

Originally posted by **natuanorg** May 28, 2024 We are currently using React Native Skia for image rendering in our application and have noticed that the image quality is significantly lower compared to when using the expo-Image library. Here is a sample code snippet for rendering an image using React Native Skia and expo-image to illustrate the issue: ```ts const URI = 'https://i.ibb.co/D1rZQvR/2024.webp'; export const TestScreen = () => { const image = useImage(URI); if (image === null) { return null; } return ( ); }; ``` ![Screenshot_20240528_224016](https://github.com/Shopify/react-native-skia/assets/7755173/d33bada1-8961-4593-ad58-6b47ec840fd8) We are looking for guidance on how to improve image rendering quality using React Native Skia. Any insights, recommendations, or configurations that could help us achieve better quality would be greatly appreciated. Thank you for your attention to this matter. We look forward to your support and suggestions.
wcandillon commented 5 days ago

@natuanorg I decided to expose a generic sampling option instead of just exposing the cubicSampling property. This means that it will take me a bit more time to ship the feature.

In the meantime you can use the imperative API to achieve your use-case via the Picture API for instance and then using the following: https://github.com/Shopify/react-native-skia/pull/2509/files#diff-cb1e83aa96ec697ad2b3321dee44b5c8828de866df1f2886a4d67e80f4bfd431R48

If you are willing to contribute to the project, that would also be an option.

natuanorg commented 2 days ago

@wcandillon We have resolved the low image quality issue by using offscreen canvas to render and export images. Thank you for your support!