# Cannot attach SVG from draw.io

**URL:** https://meta.discourse.org/t/cannot-attach-svg-from-draw-io/67587
**Category:** Bug
**Created:** [8월 7, 2017, 7:41오전 UTC](https://meta.discourse.org/t/cannot-attach-svg-from-draw-io/67587 "2017-08-07T07:41:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![toksvaeth](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@toksvaeth](https://meta.discourse.org/u/toksvaeth)
#### Post date: [8월 7, 2017, 7:41오전 UTC](https://meta.discourse.org/t/cannot-attach-svg-from-draw-io/67587/1 "2017-08-07T07:41:14Z")

</div>

Hello,

I use [draw.io](https://www.draw.io/) to render technical diagrams. It is often of benefit to attach these to discussion topics to further a conversation or demonstrate an idea. [Draw.io](http://Draw.io) has the ability to export in [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) format, which is my preference when working with other discussion software.

When attempting to attach an SVG image generated through [draw.io](http://draw.io) to a Discourse topic, I am unable to do so. Instead, I receive this error:

> Sorry, but we couldn’t determine the size of the image. Maybe your image is corrupted?

I am currently uncertain if there is something special about the SVG format that [draw.io](http://draw.io) uses, or if Discourse is having trouble dealing with SVG files.

### Steps to reproduce

A sample SVG file is [available for your use](https://drive.google.com/file/d/0B3nYxBFHc-AZa1BGQzVaOF81a0E/view?usp=sharing). Alternatively, follow the steps below:

1. Head to [draw.io](http://draw.io) and start a new diagram.
2. Add any arbitrary shape (just one is fine) to the diagram.
3. Head to _File_ \> _Export As_ \> _SVG…_
4. Accept the defaults and hit _Export_.
5. Create a new Discourse topic.
6. Attempt to upload your SVG file.

**Expected Result** : SVG file is attached to the topic and (hopefully) rendered for users.

**Actual Result** : Unable to attach file. Error message received as follows:

> Sorry, but we couldn’t determine the size of the image. Maybe your image is corrupted?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [8월 7, 2017, 8:32오전 UTC](https://meta.discourse.org/t/cannot-attach-svg-from-draw-io/67587/3 "2017-08-07T08:32:48Z")

</div>

Best #Contribute > Bug report I’ve seen in a while 👍

Turns out, [draw.io](http://draw.io) exports SVGs with a `<!DOCTYPE>` which isn’t supported by [the library](https://github.com/sdsykes/fastimage) we use to determine the image’s dimension.

Made a [PR](https://github.com/sdsykes/fastimage/pull/93) and pushed a [temp gem](https://rubygems.org/gems/discourse_fastimage) so we can use it 😉

> <https://github.com/discourse/discourse/commit/ad20f598974ccfc48d89b4a46d6093c057a2108f>

---

<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: [8월 7, 2017, 6:43오후 UTC](https://meta.discourse.org/t/cannot-attach-svg-from-draw-io/67587/4 "2017-08-07T18:43:27Z")

</div>


