-
I having trouble to read .heic image with Skia. How to solve it? const data = await Skia.Data.fromURI('path/to/image.heic');
const image = Skia.Image.MakeImageFromEncoded(data); Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
jinookoo
Jul 26, 2024
Replies: 3 comments 1 reply
-
Have you found a way to solve this problem? I also encountered the same problem. |
Beta Was this translation helpful? Give feedback.
1 reply
-
It's temporary solutions import {Skia, ImageShader, SkImage, DataSourceParam, useImage} from '@shopify/react-native-skia';
import {SaveFormat, manipulateAsync} from 'expo-image-manipulator';
import {useEffect, useState} from 'react';
import {useCanvasStore} from './context/canvas';
type Props = {
file: DataSourceParam;
};
export const NextImage = ({file}: Props) => {
const {width, height} = useCanvasStore();
const defaultImage = useImage(file);
const [image, setImage] = useState<SkImage>(defaultImage);
useEffect(() => {
if (!defaultImage && typeof file === 'string') {
manipulateAsync(file, [], {
compress: 0.8,
format: SaveFormat.JPEG,
}).then(async ({uri}) => {
const skData = await Skia.Data.fromURI(uri);
const skImage = Skia.Image.MakeImageFromEncoded(skData);
setImage(skImage);
});
}
}, [defaultImage, file]);
if (!image) {
return null;
}
return <ImageShader fit="contain" image={image} rect={{x: 0, y: 0, width, height}} />;
};
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hungtooc
-
hi @wcandillon any updates on this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's temporary solutions
If you convert image format to jpeg
It works