react-native-image-resizer icon indicating copy to clipboard operation
react-native-image-resizer copied to clipboard

Ios 11 new HEIC image format. Error 'Only JPEG and PNG format are supported by createResizedImage'

Open antakov opened this issue 7 years ago • 15 comments

Hi. There is an error caused by new Apple image format.

5ba6170fda

antakov avatar Oct 05 '17 08:10 antakov

I got this too.

Cygnus2112 avatar Oct 10 '17 01:10 Cygnus2112

Yup me too!

srameshr avatar Oct 25 '17 08:10 srameshr

Ping @4ian Any solutions for this issues please.

BANG88 avatar Nov 07 '17 05:11 BANG88

You can avoid the error by specifying "JPEG" as format in arguments, eg.:

const resizedImage = await ImageResizer.createResizedImage(...., 1024, 1024, 'JPEG', 90);

pfeiffer avatar Nov 07 '17 07:11 pfeiffer

Any updates on this? @pfeiffer suggestion does not seem to work.

srshah19 avatar Dec 06 '17 01:12 srshah19

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.

edi avatar Jan 12 '18 12:01 edi

@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 avatar Jan 13 '18 01:01 BANG88

@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 ?

Code

Thanks

edi avatar Jan 16 '18 13:01 edi

@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.

BANG88 avatar Jan 16 '18 14:01 BANG88

Ah, understood :) Will give it a try now

edi avatar Jan 16 '18 14:01 edi

It should work. hah.

BANG88 avatar Jan 16 '18 14:01 BANG88

keeMeta option does NOT work on HEIC threated as jpeg :/

HugoGresse avatar Jul 23 '20 09:07 HugoGresse

keeMeta option does NOT work on HEIC threated as jpeg :/

@HugoGresse up, how did you fix this issue?

baiross avatar Nov 10 '20 15:11 baiross

I did not :/

HugoGresse avatar Nov 10 '20 16:11 HugoGresse

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

socialcode-rob1 avatar Apr 09 '22 14:04 socialcode-rob1

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.

stale[bot] avatar Sep 01 '22 18:09 stale[bot]

This issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Sep 08 '22 18:09 stale[bot]