react-native-image-resizer
react-native-image-resizer copied to clipboard
Ios 11 new HEIC image format. Error 'Only JPEG and PNG format are supported by createResizedImage'
Hi. There is an error caused by new Apple image format.
I got this too.
Yup me too!
Ping @4ian Any solutions for this issues please.
You can avoid the error by specifying "JPEG" as format in arguments, eg.:
const resizedImage = await ImageResizer.createResizedImage(...., 1024, 1024, 'JPEG', 90);
Any updates on this? @pfeiffer suggestion does not seem to work.
Any solutions ? I'm trying to upload images ... but .. they are HEIC format .. so I figured I could use a resizer, but then ... I get this error when trying to resize in order to convert from HEIC to JPG.
@EduardJS I treat them as JPEG and no errors at the moment
export enum SupportedFileTypes {
'PNG' = 'PNG',
'JPEG' = 'JPEG',
/**
* IOS 11 image format
*/
'HEIC' = 'JPEG',
'JPG' = 'JPEG',
}
@bang88 Could you elaborate your code ? I can see this is TS, and there's only one .ts file in the project, but how exactly are you using it ? Something like this maybe ?
Thanks
@EduardJS sorry for make confusing. I mean you can check the file extension if it is HEIC
format. you can treat it as an jpeg file.
Ah, understood :) Will give it a try now
It should work. hah.
keeMeta option does NOT work on HEIC threated as jpeg :/
keeMeta option does NOT work on HEIC threated as jpeg :/
@HugoGresse up, how did you fix this issue?
I did not :/
One option is to use a HEIC converter prior to resizing.
if (response.filename && response.filename.endsWith('HEIC')) {
RNHeicConverter.convert({path: response.sourceURL}).then((converted) => {
// ... image resizer logic
});
} else if (response.mime.match(/image\/jpeg|image\/png/)) {
// ... image resizer logic
}
Library used in example: react-native-heic-converter
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed. Thank you for your contributions.