Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Conversion from Markdown to docx produces images of fixed size #976

Closed
ben opened this Issue · 6 comments

3 participants

@ben
ben commented

I'm having an issue where images included from markdown aren't sized appropriately; they appear to all be pinned to 1.67" square. This is easily reproducible:

$ pandoc -t docx -o test.docx
![Caption](a_400x100_image.jpg

Expected output: a document with an embedded image that, if too wide, is clamped to the margin area, but honors its original aspect ratio.

Actual output: a document that looks like this (screenshot from Word for Mac 2011):

hi docx compatibility mode -1

Here's the image that's being included. It's 400x100 at 72dpi.

a_400x100_image

Is there some flag I can pass to bypass this behavior? It also happens if I round-trip to LaTeX, and the LaTeX output doesn't look like it's embedding any size information:

$ pandoc -f markdown -t latex
![Caption](a_400x100_image.jpg)

The output:

\begin{figure}[htbp]
\centering
\includegraphics{a_400x100_image.jpg}
\caption{Caption}
\end{figure}
@ben
ben commented

I should mention this is version 1.11.1:

$ pandoc --version
pandoc 1.11.1
Compiled with citeproc-hs 0.3.8, texmath 0.6.1.3, highlighting-kate 0.5.3.8.
Syntax highlighting is supported for the following languages:
    actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
    clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
    diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
    fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,
    javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell,
    lua, makefile, mandoc, matlab, maxima, metafont, mips, modula2, modula3,
    monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, pascal,
    perl, php, pike, postscript, prolog, python, r, relaxngcompact, rhtml, ruby,
    rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl,
    texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml
Default user data directory: /Users/ben/.pandoc
Copyright (C) 2006-2013 John MacFarlane
Web:  http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions.  There is no
warranty, not even for merchantability or fitness for a particular purpose.
@jgm
Owner
jgm commented
@ben
ben commented

I'm using both Skitch and Photoshop to generate JPGs, and images from both sources have problems, so I'd expect this to be rather common. For a workaround, it looks like PNGs generated from both Skitch and Photoshop have no issues. Thanks! :grinning:

@sowiso

We have the same issue on ubuntu 12.04.
As a current workaround we pre-convert images to .png, but a fix would be nice.

@jgm
Owner
jgm commented

Here's a description of the EXIF format:
http://www.media.mit.edu/pia/Research/deepview/exif.html

@jgm jgm closed this issue from a commit
@jgm Text.Pandoc.ImageSize: Parse EXIF format JPGs.
Note:  For now we just assign them all 72 dpi.  It wasn't
clear to me how to extract the resolution information.
At least the aspect ratio will be right, and 72 dpi is
the most common setting.

Closes #976.
3bf8012
@jgm jgm closed this in 3bf8012
@jgm
Owner
jgm commented

Reopening -- the patch above will only work with some EXIF headers. Working on something more robust.

@jgm jgm reopened this
@jgm jgm closed this issue from a commit
@jgm Better exif parsing, including image resolution.
This introduces a dependency on binary >= 0.6, but we depend
on binary >= 0.5 via zip-archive anyway.

Closes #976.
5c8c380
@jgm jgm closed this in 5c8c380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.