Support for HEIC images

We have a lot of users uploading files. Apparently they are HEIC file from iPhone.

Is there a way to have these display inline for the post? (assuming this isn’t supported right now?)

4 Likes

Looks like this is a browser limitation:

https://caniuse.com/#feat=heif

heif covers both heif and heic and there’s No support for either in any mainstream browser at present

6 Likes

Ugh. So annoying Apple.

I’d say #pr-welcome for allowing users to upload those and converting those from HEIC to JPEG.

11 Likes

Is there an existing pipeline that does something similar that you could point a contributor to?

8 Likes

There is this:

https://github.com/discourse/discourse/blob/7c324118815e62c9ac978ceb62866a48eb07f3ca/lib/upload_creator.rb#L187

And there are some accompanying specs at upload_creator_spec.rb.

12 Likes

I think this would be a really awesome upgrade and doesn’t look like HEIC is going away…Thanks if someone can figure it out!

To be clear this won’t add HEIC support. Images will be converted using a different lossy method and lose a tiny bit of fidelity in the process.

Any live photos shared as HEIC will become a still image, and while HEIC can support transparency, JPEG does not.

The equivalent JPEG is about twice the size.

10 Likes

Understand. I’m ok with the tradeoffs.

1 Like

Any traction on this one?

Not at the current time, no. Did you want to sponsor the feature or submit a PR?

I took a crack at this yesterday. I work on a Mac, and this was pretty straightforward on my machine, so I set up this PR: https://github.com/discourse/discourse/pull/10079 however ImageMagick on Linux machines does not come with HEIC support out of the box, so we can’t merge this until we update the base Docker image to include HEIC support.

I’ll work on that now, but this will take a bit longer to get to core.

17 Likes

This feature is now merged in core and the base image bas been updated.

To enable HEIC/HEIF support, you need to:

  • enable the convert heif to jpeg site setting
  • add heic and/or heif to the authorized extensions for uploads on your site

If you are hosted with us, this feature should be available already (if it isn’t, shoot us a quick message).

For self-hosters, you need to update the base image and rebuild:

cd /var/discourse
git pull
./launcher rebuild app
8 Likes

Do you mean the site setting is enabled by default on our hosting?

No, it’s not enabled by default, I just meant that the new setting should be there on our hosting.

4 Likes

Is there any reason it should not be enabled by default on our hosting?

1 Like

Does it even need to be a setting?

Discourse isn’t a file manager, if people want to share the HEIC files they could just link to it hosted elsewhere?

I can’t see it doing any significant harm?

1 Like

I guess you’re right, the setting only adds a hurdle. It’s easy to remove.

Should we also add .heif/.heic to the default authorized extensions site setting @codinghorror?

6 Likes

Sure, whatever is easiest works for me!

5 Likes

Ideally this should just work out of the box, right?

Other uploads are already optimized, HEIC is just being optimized ‘a little further’ to cater for browser compatibility issues.

8 Likes