Resize image in the wiki of GitHub using Markdown
HtmlGithubMarkdownWikiHtml Problem Overview
I'm writing a wiki page on GitHub, and I'm using Markdown.
My problem is that I'm putting a large image (this image is in its own repository) and I need resize it.
I have tried different solutions, but they do not work:
![image](http://url.to/image.png "Title" {width=40px height=400px})
![image](http://url.to/image.png = 250x250)
![image](http://url.to/image.png = 250x)
[[http://url.to/image.png = 250x]]
Is there a way to get it?
It is preferable without HTML.
Html Solutions
Solution 1 - Html
Updated:
Markdown syntax for images (external/internal):
![test](https://github.com/favicon.ico)
HTML code for sizing images (internal/external):
<img src="https://github.com/favicon.ico" width="48">
Example:
Old Answer:
This should work:
[[ http://url.to/image.png | height = 100px ]]
Source: https://guides.github.com/features/mastering-markdown/
Solution 2 - Html
On GitHub, you can use HTML directly instead of Markdown:
<a href="url"><img src="http://url.to/image.png" align="left" height="48" width="48" ></a>
This should make it.
Solution 3 - Html
Almost 5 years after only the direct HTML formatting works for images on GitHub and other markdown options still prevent images from loading when specifying some custom sizes even with the wrong dimensions. I prefer to specify the desired width and get the height calculated automatically, for example,
<img src="https://github.com/your_image.png" alt="Your image title" width="250"/>
Solution 4 - Html
I have used methods described above. Now I am using the method which is a way similiar but more simple to me.
- First create add README.md file to your project.
- Then upload screenshoots or whatever description images needed to your project main directory.
- After uploading image Assets use html to refer these assets directly without using link like below
Like this:
<img src="icon.jpg" width="324" height="324">
<p align="center">
<img src="screen1.png" width="256" height="455">
<img src="screen2.png" width="256" height="455">
<img src="screen3.png" width="256" height="455">
</p>
On above example I have used paragraph to align images side by side. If you are going to use single image just use the code as below
<img src="icon.jpg" width="324" height="324">
Have a nice day!
Solution 5 - Html
Resize by Percentage width=50% height=50%
. Example:
<img src="https://i.imgur.com/ZWnhY9T.png" width=50% height=50%>
Resize by Pixels width="150" height="280"
. Example:
<img src="https://i.imgur.com/ZWnhY9T.png" width="150" height="280">
Some tips
-
To get a githubusercontent link for an image, drag and drop the image into any issue, and copy/paste the url from the code that is automatically generated. Example code:
![image](https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png)
-
There is no way to change the size of an image if the markdown format is of the form
[]()
- so stop looking right now! - you must use<img>
instead -
Another useful summary of conventions that do and don't work here
-
All of the above is from here
Solution 6 - Html
GitHub Pages now uses kramdown as its markdown engine so you can use the following syntax:
Here is an inline ![smiley](smiley.png){:height="36px" width="36px"}.
http://kramdown.gettalong.org/syntax.html#images
I haven't tested it on GitHub wiki though.
Solution 7 - Html
This addresses the different question, how to get images in gist (as opposed to github) markdown in the first place ?
In December 2015, it seems that only links to files on
github.com
or cloud.githubusercontent.com
or the like work.
Steps that worked for me in a gist:
- Make a gist, say
Mygist.md
(and optionally more files) - Go to the "Write Comment" box at the end
- Click "Attach files ... by selecting them"; select your local image file
- GitHub echos a long long string where it put the image, e.g. ![khan-lasso-squared](https://cloud.githubusercontent.com/assets/1280390/12011119/596fdca4-acc2-11e5-84d0-4878164e04bb.png)
- Cut-paste that by hand into your
Mygist.md
.
But: GitHub people may change this behavior tomorrow, without documenting it.