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

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

<div class="figure">
<img src="image.jpg" width="100%" alt="alttext" /><p class="caption">alttext</p>
</div>

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

@jgm

This comment has been minimized.

Show comment Hide comment
@jgm

jgm Nov 21, 2011

Owner

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.

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

This comment has been minimized.

Show comment Hide comment
@zhou13

zhou13 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.

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

This comment has been minimized.

Show comment Hide comment
@shrutikapoor08

shrutikapoor08 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.

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

This comment has been minimized.

Show comment Hide comment
@linquize

linquize Mar 29, 2013

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

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

@jgm

This comment has been minimized.

Show comment Hide comment
@jgm

jgm Mar 29, 2013

Owner

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.

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.

@adityam

This comment has been minimized.

Show comment Hide comment
@adityam

adityam Mar 30, 2013

Contributor

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.

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

This comment has been minimized.

Show comment Hide comment
@shrutikapoor08

shrutikapoor08 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.

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

This comment has been minimized.

Show comment Hide comment
@qris

qris 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.

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.
@nichtich

This comment has been minimized.

Show comment Hide comment
@nichtich

nichtich May 21, 2013

Contributor

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.

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.

@jgm

This comment has been minimized.

Show comment Hide comment
@jgm

jgm May 21, 2013

Owner

+++ 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!

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!

@nichtich

This comment has been minimized.

Show comment Hide comment
@nichtich

nichtich May 23, 2013

Contributor

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.

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

This comment has been minimized.

Show comment Hide comment
@sstadelman

sstadelman Dec 13, 2013

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

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

@metasim

This comment has been minimized.

Show comment Hide comment
@metasim

metasim Jan 28, 2014

+1 for /some/ sort of solution.

metasim commented Jan 28, 2014

+1 for /some/ sort of solution.

@Who8MyLunch

This comment has been minimized.

Show comment Hide comment
@Who8MyLunch

Who8MyLunch Feb 14, 2014

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

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

@thriveth

This comment has been minimized.

Show comment Hide comment
@thriveth

thriveth 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.

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

@mb21

This comment has been minimized.

Show comment Hide comment
@mb21

mb21 Oct 6, 2014

Collaborator

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

Collaborator

mb21 commented Oct 6, 2014

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

@strout

This comment has been minimized.

Show comment Hide comment
@strout

strout Feb 21, 2016

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

strout commented Feb 21, 2016

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

@jgm

This comment has been minimized.

Show comment Hide comment
@jgm

jgm Feb 21, 2016

Owner

This can be closed.

Owner

jgm commented Feb 21, 2016

This can be closed.

@jgm jgm closed this Feb 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment