Resize image in the wiki of GitHub using Markdown

236,841

Solution 1

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:

test


Old Answer:

This should work:

[[ http://url.to/image.png | height = 100px ]]

Source: https://guides.github.com/features/mastering-markdown/

Solution 2

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

I have used methods described above. Now I am using the method which is a way similiar but more simple to me.

  1. First create add README.md file to your project.
  2. Then upload screenshoots or whatever description images needed to your project main directory.
  3. 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 4

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 5

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

Share:
236,841
fhuertas
Author by

fhuertas

Updated on July 11, 2022

Comments

  • fhuertas
    fhuertas almost 2 years

    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.

  • fhuertas
    fhuertas almost 10 years
    Thanks for the solution, is it possible without html code?
  • Sam Dutton
    Sam Dutton almost 9 years
    Thanks. <img src="..." width="48"> works in READMEs for images uploaded to GitHub.
  • Jonik
    Jonik over 8 years
    @SamDutton: It seems to work fine also for images hosted elsewhere.
  • I'm a frog dragon
    I'm a frog dragon over 8 years
    Just want to note that you can exclude the width so that it can scale the width based on height automatically.
  • koppor
    koppor almost 8 years
    Where is the resize aspect?
  • Nicolas Miari
    Nicolas Miari over 7 years
    Not just on Github; I believe inline HTML is allowed within Markdown in general...
  • spikeyang
    spikeyang over 7 years
    Test it today. Github won't recognize the syntax of [](.. =400) or [](... =400px), so if I need to resize the picture, I have to use the <img/> syntax.
  • Allen Vork
    Allen Vork about 7 years
    what about a gift
  • Julian
    Julian about 7 years
    When you replace the markdown syntax with the html, you don't see the correct size in the Github preview. But it does work :)
  • Eduardo
    Eduardo over 6 years
    The crossed out answer works if the image is added to the wiki itself.
  • user310291
    user310291 about 6 years
    @nicobo I tried seems it doesn't work for external image ?
  • DanMad
    DanMad almost 6 years
    What @Eduardo said... The 'Old Answer' that you have crossed out is what I have been scouring the internet for—still works great for relative paths (assets inside the wiki). Additionally, I had to add one or two images inside of a table. The pipe character was giving me grief because of typical table formatting in markdown. Escaping the pipe inside a table cell is still valid: [[ http://url.to/img.png \| height=48px]].
  • DavidJ
    DavidJ over 5 years
    This works in GitHib pages using Jekyll, FYI (I realize this isn't precisely the OPs question)
  • shim
    shim almost 4 years
    I wrote this script which can be added to Automator using a Javascript quick action and then with a keyboard shortcut you can quickly convert the automatically generated Github image markdown with the HTML for easy resizing while the text is selected. I would also recommend submitting feedback to Github to get them to simplify this.
  • Rishabh B
    Rishabh B over 2 years
    The question clearly asks to resize image using Markdown, so could you provide a method to do it in this way. I searched around internet, but no concrete answer. I don't think this should be an accepted answer.