# CR2 raw files are being treated as tiff files

**URL:** https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775
**Category:** Feature
**Created:** [9 september 2018 om 04:13 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775 "2018-09-09T04:13:27Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [9 september 2018 om 04:13 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/1 "2018-09-09T04:13:27Z")

</div>

This is just for tracking the issue. The bug is actually in fastimage and reported here:

[https://github.com/sdsykes/fastimage/issues/104](https://github.com/sdsykes/fastimage/issues/104)

Directly to the twitter discussion about the issue

> <https://twitter.com/darixzen/status/1038185056395776003>

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9 september 2018 om 04:32 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/2 "2018-09-09T04:32:01Z")

</div>

If the bug is in fastimage then it is not a bug in Discourse…

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [9 september 2018 om 07:22 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/3 "2018-09-09T07:22:13Z")

</div>

Raw file full on support is going to have to be plugin area. In general these files are 10-30 megs and dealing with them is quite a nightmare cause we would need [http://www.cybercom.net/~dcoffin/dcraw/](http://www.cybercom.net/~dcoffin/dcraw/) in our image and in general even photographers do not like sharing raw files which are usually considered “my private blueprint”

That said…

We recently introduced a fix that looks at the actual contents of files prior to treating them as an image. This happened cause gravatar did not care about file extensions and would return `jpegs` as `png` so we went all atomic now and “coerce” images to correct file types.

raw files tend to “look” like tiff files cause they tend to use a tiff container. This does not really matter to us anyway cause the “image extension correction” should only apply to png/jpeg/gif… everything else really should be treated as attachments and not pass through file extension coercion.

I think we should narrow down “supported images” down here:

> <https://github.com/discourse/discourse/blob/main/lib/file_helper.rb#L106>

`tif` / `tiff` / `webp` should be removed due to uneven browser support and simply treated as attachments. see:

> **[Comparison of web browsers | Image format support](https://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support)**
>
> Information about what image formats the browsers support. External links lead to information about support in future versions of the browsers or extensions that provide such functionality.

Chrome has no support for tif, not-chrome has no support for webp.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [9 september 2018 om 15:12 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/5 "2018-09-09T15:12:19Z")

</div>

I removed tiff and tif from the list and it actually works as we want. I  
think I will patch that in our package for now.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9 september 2018 om 20:27 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/6 "2018-09-09T20:27:15Z")

</div>

Do we even need `.bmp` there while we are at it?

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [9 september 2018 om 22:07 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/7 "2018-09-09T22:07:49Z")

</div>

fastimage now skips raw files:

[https://github.com/sdsykes/fastimage/issues/104#event-1834709521](https://github.com/sdsykes/fastimage/issues/104#event-1834709521)

I asked for a release.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [10 september 2018 om 01:04 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/8 "2018-09-10T01:04:47Z")

</div>

Really not sure, technically there is cross browser support, but yeah lightboxing a bmp makes little sense and I can no see any kind of scenario where you would want a bmp as a site asset (ico though we do render so I don’t want to play with the pipeline for it)

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [10 september 2018 om 10:14 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/9 "2018-09-10T10:14:16Z")

</div>

New release out [fastimage | RubyGems.org | your community gem host](https://rubygems.org/gems/fastimage/versions/2.1.4)

removed my discourse-skip-tiff.patch and ran discourse with fastimage 2.1.4. Works nicely.

So can we get the changes for the 2.1.0 release?

1. push fastimage 2.1.4 update
2. removing tif\* + bmp from the list

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2 november 2018 om 05:32 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/10 "2018-11-02T05:32:35Z")

</div>

tif support is now dropped which is good and tif is simply treated same as cr2, as a binary which is attached.

> <https://github.com/discourse/discourse/blob/42340583582c11d4acc3008f36ad91cbfec279c6/lib/file_helper.rb#L103-L105>

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5 november 2018 om 07:06 UTC](https://meta.discourse.org/t/cr2-raw-files-are-being-treated-as-tiff-files/96775/11 "2018-11-05T07:06:13Z")

</div>

This topic was automatically closed after 3 days. New replies are no longer allowed.
