19

I want to downsize some of my images in my README.md on GitHub and it works fine in my Markdown editor using something like

![](./images/my_img.png =400x)

However, when I upload it to GitHub, the Markdown viewer seems to not like it. Any suggestions or ideas how I can downsize the images without reducing the resolution of the images themselves?

2 Answers2

43

Github doesn't apply the style attribute but obeys the width and height. So for github you can use the following HTML tag directly in the markdown:

<img src="url" alt="alt text" width="whatever" height="whatever">
tzolov
  • 601
  • 7
  • 5
13

You can use HTML syntax for the image directly in markdown

## Markdown Header

This is a markdown paragraph. Etc.

<img src="url" alt="alt text" style="width:whatever;height:whatever">

Update: As tzolov notes, GitHub doesn't actually permit inline styles. His technique does work, though.

Stephen Thomas
  • 13,843
  • 2
  • 32
  • 53
  • is there a way I can set the height relative to the width (and vice versa), would make it easier, since the dimensions for the different images might be/are different –  Mar 18 '14 at 17:59
  • alas not. (well technically there is a way using the `background-image` property, but it's way more trouble than it's worth in this case.) – Stephen Thomas Mar 18 '14 at 19:10
  • 1
    Um.. not sure if I understand @SebastianRaschka right, but simply specifying *only* width or height should scale the other dimension accordingly. – ojdo Sep 22 '14 at 16:54
  • 8
    Doesn't work on github, image is there, but in its original size, github seems to filter out the `style` attribute... – Alexander Klimetschek Oct 14 '14 at 23:15
  • 1
    Doesn't work, @tzolov's answer should be marked as correct one – Azat Oct 25 '15 at 12:20
  • 1
    `style=""` does not work in github. The post form @tzolov should appear higher. – 0xPingo Oct 28 '15 at 03:49