# Syntax for specifying image size #261

Closed
opened this Issue Jun 10, 2011 · 117 comments

Projects
None yet
Owner

### jgm commented Jun 10, 2011

 Googlecode Issue #29 There is currently no way to specify the size of an image. For some ideas, see http://code.google.com/p/pandoc/wiki/ImageSizes.
Owner

### jgm commented Jun 10, 2011

 Comment 2 by schm...@gmx.de, Nov 10, 2010 You can enter the dimensions of an image in the header of the JPG or PNG files. LaTeX and the DocBook processors will use that size. In HTML output you can set the size for every image in a separate CSS file.

### candlerb commented Jul 19, 2011

 Duplicate of #61 ?

Closed

Closed

### seanfarley commented Oct 15, 2012

 I'd like to say for the record that all of the advice for image manipulation (see above) doesn't help at all when dealing with vector image formats (svg, TikZ, pdf, etc.). This issue is quite the wrench.

### pckujawa commented Apr 22, 2013

 @jgm mentions that You can enter the dimensions of an image in the header of the JPG or PNG files. I'm not sure what that means. Where does one specify the header of one of these image files? I assume this isn't in reference to the bytes of the image file itself.
Owner

### jgm commented Apr 22, 2013

 +++ pckujawa [Apr 22 13 00:53 ]: [1]@jgm mentions that  You can enter the dimensions of an image in the header of the JPG or PNG files.  I'm not sure what that means. Where does one specify the header of one of these image files? I assume this isn't in reference to the bytes of the image file itself. The DPI is stored in metadata in the header of the image files. You can view and manipulate it with most image manipulation programs (e.g. Gimp, Photoshop). I like to use ImageMagick command line tools, myself. convert -units PixelsPerInch my.jpg -density 300 my.new.jpg 

### pckujawa commented Apr 23, 2013

Contributor

### adityam commented Apr 24, 2013

 From what I understand, there is no consensus on markdown syntax to specify the width of an image. For that reason, width specifications are not supported.
Contributor

### adityam commented Apr 24, 2013

 Similar to HTML+CSS, ConTeXt allows you to specify the dimensions of individual figures. You can create a figures.tex file: \defineexternalfigure[filename.ext][width=..., height=...] \defineexternalfigure[filename.ext][width=..., height=...]  Then generate a ConTeXt file using pandoc -t context -s output.tex  and compile it using context --environment=figures.tex output.tex 

Contributor

### nichtich commented Jun 13, 2013

 Just a note: if image size should be specified in Pandoc Markdown, one must be able to specify at least two kinds of sizes: first the size in cm or inch for PDF, DocBook, Word etc. and second the size in pixels for HTML, EPUB and related output formats. For bitmap image files both can also be specified in the image files but vector image files usually contain no pixel dimensions.
Collaborator

### mb21 commented Jul 22, 2013

 A TeX hack to get floating images in ConTeXt is to redifine \externalfigure: \let\externalfigureOrig\externalfigure \def\externalfigure[#1]{\placefigure[right]{}{\externalfigureOrig[#1]}} 
Contributor

Owner

### jgm commented Nov 23, 2015

 https://hackage.haskell.org/package/cryptonite says it supports Windows >= 8. Is Windows 2003 < Windows 8? If so, that's your problem. +++ TIm St.Clair [Nov 22 15 21:19 ]: Windows 2003 R2 Sp2 32-Bit, on VirtualBox; git, node, cygwin, miktex, haskell platform, cabal, etc all installed and updated ok. (ghc version 7.8.3) \$ stack install Downloading lts-3.13 build plan ...FailedConnectionException2 "raw.githubusercon tent.com" 443 True user error (cryptonite: random: cannot get any source of entr opy on this system) when compiling via cabal, I also get cryptonite can't be installed (cryptonite: random: cannot get any source of entropy on this system). — Reply to this email directly or [1]view it on GitHub. References

### frumbert commented Nov 23, 2015

 slaps forehead compiling happily on my win10 box... i really have to trash that old thing and stop using it.

### Wind4Greg commented Dec 8, 2015

 I really want this feature but can't get Pandoc to build with stack on Windows 10. Followed the instructions from https://github.com/jgm/pandoc/wiki/Installing-the-development-version-of-pandoc, downloaded the latest stack from http://docs.haskellstack.org/en/stable/install_and_upgrade.html#windows. But I get a weird error seemingly unrelated to Pandoc:  C:\Users\Greg\AppData\Local\Temp\stack5940\HTTP-4000.2.21\Network\HTTP\Proxy.hs:85:22: Not in scope: ‘liftM’ Perhaps you meant ‘liftM2’ (imported from Control.Monad)  Which has something to do with a Haskell HTTP library. Is there any other way to get this feature? Or is there something about Haskell on windows that I'm overlooking.
Owner

### jgm commented Dec 8, 2015

 Someone has reported the same issue on pandoc-discuss. I haven't had a chance to build yet on a Windows machine or investigate further. +++ Greg Bernstein [Dec 08 15 11:31 ]: I really want this feature but can't get Pandoc to build with stack on Windows 10. Followed the instructions from [1]https://github.com/jgm/pandoc/wiki/Installing-the-development-versio n-of-pandoc, downloaded the latest stack from [2]http://docs.haskellstack.org/en/stable/install_and_upgrade.html#wind ows. But I get a weird error seemingly unrelated to Pandoc: C:\Users\Greg\AppData\Local\Temp\stack5940\HTTP-4000.2.21\Network\HTTP\Proxy .hs:85:22: Not in scope: ‘liftM’ Perhaps you meant ‘liftM2’ (imported from Control.Monad) Which has something to do with a Haskell HTTP library. Is there any other way to get this feature? Or is there something about Haskell on windows that I'm overlooking. — Reply to this email directly or [3]view it on GitHub. References

### Wind4Greg commented Dec 8, 2015

 Thanks. It's a windows/Haskell issue, using a VM was able to build it on Ubuntu and see first hand this really nice feature. I'll watch pandoc-discuss for the windows fix. Cheers.

### mindv0rtex commented Mar 31, 2016

 Is there an estimate of when this feature will reach the release?
Collaborator

### mb21 commented Mar 31, 2016

 Image dimensions have been in 1.16 for a while already...

Closed

### mofosyne commented May 17, 2016

 How do you use it btw? I can't seem to find instructions on using it in the manual.

### KurtPfeifle commented May 18, 2016

 Search for link_attributes. See here: http://pandoc.org/README.html#images

Closed

### flrgsr commented Jun 16, 2017 • edited Edited 1 time flrgsr edited Jun 16, 2017 (most recent)

 It seems this only works with the width and height keyword. What about scale? I would love to be able to do something like this: ![image description](images/myimage.png){ scale=0.5 } Am I missing something or is this really impossible yet? edit: I care about the latex backend So as desired output I would like to have: \begin{figure} \centering \includegraphics[scale=0.5]{images/myimage.png} \caption{the caption goes here} \end{figure}

### labdsf pushed a commit that referenced this issue Nov 5, 2017

 image attributes, pandoc #261 
 545a57e 

### JonasT commented Nov 21, 2017 • edited Edited 2 times JonasT edited Nov 21, 2017 (most recent) JonasT edited Nov 21, 2017

 Similarly to @flrgsr I would like to be able to scale images, mainly so that I don't need to make all my images super low-res and/or hardcode the image sizes in the markdown just to accommodate the scaling with HTML (which is super low DPI per default).
Collaborator

### mb21 commented Nov 21, 2017

 It sounds what you guys are really looking for is: ![](image.jpg){srcset="image_2x.jpg 2x"} 

### JonasT commented Nov 21, 2017 • edited Edited 2 times JonasT edited Nov 21, 2017 (most recent) JonasT edited Nov 21, 2017

 Yes! Is there a nicer way to write that? Also, does that work with all backends (e.g. both PDF and HTML)? Edit: also if this actually scales up/down the pixels before inserting the image that doesn't help, since then it will reduce the resolution. I can do that myself in GIMP - the point is scaling down the size without reducing the image resolution to support high DPI output properly
Collaborator

### mb21 commented Nov 21, 2017

 Depending on your taste, it's already quite nice.. (at least it's consistent with other syntax) see http://pandoc.org/MANUAL.html#extension-link_attributes for the rationale. No, if you generate your PDF with LaTeX (which is the default), it will use image.jpg. You can always write a filter that scales your images, or write some CSS to your needs...

### JonasT commented Nov 21, 2017

 So what about HTML? HTML is one of my required main targets so if it's not working nicely there, sadly I can't really use it. Filters are often mentioned here, but I consider them quite uninteresting since they require something outside markdown. Similar to CSS, except CSS is even a lot worse since it requires specific stuff for one output format only. Write once in a universal format, output to all targets shouldn't require this..
Collaborator

### mb21 commented Nov 21, 2017

 So what about HTML? What about it? Tell us what HTML you expect pandoc to generate for what input... Filters are often mentioned here, but I consider them quite uninteresting since they require something outside markdown. That's not correct. Filters are for you to customize pandoc's behaviour, see https://pandoc.org/scripting.html But this discussion/QA should move to pandoc-discuss. This issue is closed and we're spamming the people subscribed to it.