# markdown additional Image width parameter for HTML/Epub, LaTeX/PDF output formats #350

Closed
wants to merge 5 commits into
from

## Conversation

Projects
None yet

### rwst commented Nov 21, 2011

 Hello, this resolves #332 and provides implementations in the HTML and LaTeX writers. It is dependent on the two patches What does it do? The markdown ![alttext](image.jpg)  will produce markdown output ![alttext](image.jpg)@100  or HTML output 

alttext

 or LaTeX output \begin{figure}[htbp] \centering \includegraphics[width=1.0\textwidth]{image.jpg} \caption{alttext} \end{figure}  Any digits after the @ character will be interpreted as width percentage, atm

### rwst added some commits Nov 21, 2011

 add optional sizeinfo to Image pattern, with default 
 758378a 
 add handling of Image size parameter as percentage of textwidth 
 7d80f42 
 add fourth Image param, without providing parsing code, setting just … 
…a default
 fd1916d 
 add fourth Image param, without providing output code 
 3ab2164 
 output Image sizeinfo 
 ccb0885 
Owner

### jgm commented Nov 21, 2011

 I do appreciate the patch, but it is not going to be merged. In the future it would be better to discuss proposed syntax extensions on the pandoc-discuss list first, before coding anything. Image size syntax has been discussed before, and there are a number of intertwined issues that I haven't resolved. I don't want to make changes to the Pandoc type or especially the markdown syntax until I'm really convinced they're the best option. I think there are a couple of more natural and markdownish proposals than the one you implement here.

### zhou13 commented Sep 21, 2012

 I really hope that we can adjust image's size in pandoc. This bug has already lasted for 2 years.... And this patch really solve the problem.

### shrutikapoor08 commented Mar 28, 2013

 Since everyone is having an issue with the image sizing in Pandoc, I think it is really necessary to have this included in Pandoc.

### linquize commented Mar 29, 2013

 This is a +1 feature. We have been waiting for long time
Owner

### jgm commented Mar 29, 2013

 Why is it such a problem to resize the image itself? It just takes one call to ImageMagick's convert or mogrify command to do this. You can also set the DPI, so that a single image will render at the right size in both HTML and LaTeX. For example, mogrify -density 150 -resize 300x300 my.jpg  will give you an image that displays on the web as 300x300 pixels, and as a 2 inch (300/150) square in LaTeX/PDF. Is the problem that the PDF image will then be too low-res? If so, one could easily create two images, one for the PDF and one for the HTML.
Contributor

### adityam commented Mar 30, 2013

 Or just use a preprocessor like gpp. When I need more control over an image, I write <##externalfigure filename|caption|height|width>  where externalfigure is a gpp macro that translates to the appropriate HTML and (in my case) ConTeXt syntax.

### shrutikapoor08 commented Apr 15, 2013

 It is a problem because it is not intuitive and simple and it is contrary to what one expects out of pandoc markdown - simplicity. The whole purpose of using pandoc is to shred hard syntax or else one could have just used LaTeX itself. Resizing an image is such a simple thing and it shouldn't require to install any third-party libraries/ modules.

### qris commented May 3, 2013

 Yes I can manually munge each image file, but couldn't Pandoc behave sensibly by default, as @shrutikapoor08 suggested? That would make it easier to use. What if I can't find a single DPI setting that's appropriate for all output formats? e.g. a Beamer presentation and a printable document might want images at different sizes, but changing the DPI value in the image file affects both. A documented means of controlling/overriding the image size would be extremely useful. (I don't know Latex well) A solution independent of markup language would be useful, as I use RST and not Markdown, so the above patches won't help me. Something I can add to the Pandoc template would be ideal.
Contributor

### nichtich commented May 21, 2013

 The image size could depend on output format, so coding it in Markdown may be the wrong place. Pandoc is for text - maybe we need some kind of "panimage" to convert one image to different output formats, suitable for inclusion in PDF, HTML etc. One could also include videos this way. Anyway this feature is important but out of the core scope of Pandoc.
Owner

### jgm commented May 21, 2013

 +++ Jakob Voss [May 21 13 09:43 ]: The image size could depend on output format, so coding it in Markdown may be the wrong place. Pandoc is for text - maybe we need some kind of "panimage" to convert one image to different output formats, suitable for inclusion in PDF, HTML etc. There is -- it's called ImageMagick!
Contributor

### nichtich commented May 23, 2013

 Use of convert or mogrify together with Pandoc could still be simplified. For instance one should be able to scale an image to a specific width and height in mm or inch without having to calculate DPI and pixel. To improve usability we might need to collect use cases. For instance for slides one might want to scale some images to 100% width or 100% height, for PDF image size should be set in cm or inch, and for HTML/EPUB one needs size in pixel. Having to set all these values manually for all images feels wrong, both if specified in Markdown or if set in the image files.

### sstadelman commented Dec 13, 2013

 I've looked at a lot of solutions, and this is by far the cleanest. nicely done

### metasim commented Jan 28, 2014

 +1 for /some/ sort of solution.

### Who8MyLunch commented Feb 14, 2014

 It would be great to have an elegant solution for this problem.

### thriveth commented Mar 14, 2014

 I second the call for an implementation of this. It doesn't have to be super fancy. Just a percentage is fine.
Collaborator

### mb21 commented Oct 6, 2014

 Note that the discussion on image dimensions is concentrated in this issue.

### strout commented Feb 21, 2016

 Is this PR still relevant now that #261 is closed? Should it be closed?
Owner

### jgm commented Feb 21, 2016

 This can be closed.