简体   繁体   English

在本机(或 nodejs)中将 heic/heif 转换为 jpg

[英]Converting heic/heif to jpg in react native (or nodejs)

I have a react native app on ios where users can upload photos.我在 ios 上有一个反应本机应用程序,用户可以在其中上传照片。 I resize these photos server-side with sharp .我用sharp在服务器端调整这些照片的大小。 The problem is: the HEIC/HEIF-files from ios are not compatible with sharp.问题是:来自 ios 的 HEIC/HEIF 文件与 sharp 不兼容。 I get the following error:我收到以下错误:

¡Error: source: bad seek to 2808991
heif: Unsupported feature: Unsupported codec (4.3000)
¿

Is there a way to get a JPG version of the photo?有没有办法获得照片的 JPG 版本? It's also ok if I have to convert the file to jpg on the server, but how can I detect the codec of the image (so that only HEIC/HEIF images are converted, and not jpg or png)?如果我必须在服务器上将文件转换为 jpg 也可以,但是我如何检测图像的编解码器(以便仅转换 HEIC/HEIF 图像,而不转换 jpg 或 png)?

How can I convert them client side or server side?如何将它们转换为客户端或服务器端?

React Native Image Resizer can perform HEIC to jpeg compression on the app. React Native Image Resizer可以在应用程序上执行 HEIC 到 jpeg 压缩。 It's a native module so you'll have to build a development client if you're using expo.这是一个本机模块,因此如果您使用 expo,则必须构建一个开发客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM