Cscott has uploaded a new change for review. https://gerrit.wikimedia.org/r/98556
Change subject: Use exiftool to strip resolution information from JPEGs to avoid a LaTeX error. ...................................................................... Use exiftool to strip resolution information from JPEGs to avoid a LaTeX error. XeLaTeX will fail with a "dimension too large" error if the computed "actual size" of the image is excessive. For instance, if the JFIF X/Y resolution value is set to "1dpi" and the image is 1200x800, \includegraphics will fail. Strip the X/Y resolution information with exiftool during image processing to avoid this failure (we scale the image to fit the column widths anyway, the EXIF dpi information is irrelevant). Change-Id: I33e08508ce117b8843430bd23ac80ebaf321f1ca --- M .travis.yml M README.md M lib/index.js 3 files changed, 23 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer refs/changes/56/98556/1 diff --git a/.travis.yml b/.travis.yml index 24388ca..1606011 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ - "0.8" before_install: - sudo apt-get update -qq - - sudo apt-get install -qq texlive-xetex texlive-latex-recommended texlive-fonts-recommended latex-xcolor imagemagick librsvg2-bin unzip + - sudo apt-get install -qq texlive-xetex texlive-latex-recommended texlive-fonts-recommended latex-xcolor imagemagick librsvg2-bin unzip libimage-exiftool-perl - mkdir ~/texmf - unzip -d ~/texmf texdeps/fontspec.tds.zip - cp -r ~/texmf/tex/latex ~/texmf/tex/xelatex diff --git a/README.md b/README.md index a75cbc9..13c1000 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Install other system dependencies. ``` -apt-get install texlive-xetex texlive-latex-recommended texlive-fonts-recommended latex-xcolor imagemagick librsvg2-bin unzip +apt-get install texlive-xetex texlive-latex-recommended texlive-fonts-recommended latex-xcolor imagemagick librsvg2-bin unzip libimage-exiftool-perl ``` Note that up-to-date LaTeX `hyperref` and `fontspec` packages are diff --git a/lib/index.js b/lib/index.js index 686074f..2845581 100644 --- a/lib/index.js +++ b/lib/index.js @@ -637,6 +637,23 @@ }); +// Remove JFIF resolution information from JPGs; bogus resolution information +// can cause LaTeX to abort with a "dimension too large" error if the +// computed "actual size" of the image is enormous (regardless of the fact +// that we're going to scale it to fit anyway). +// Takes a {imagedir,filename}, returns a promise for an +// {imagedir,filename} with the converted filename. +var convertJpg = guard(guard.n(5), function(info) { + return P.spawn('exiftool', [ + '-JFIF:All=', '-overwrite_original', + path.join(info.imagedir, info.filename) + ]).then(function() { + // no change in filename (overwrite in place) + return info; + }); +}); + + // return a promise for a map from file resource URLs to on-disk filenames // (after image processing / renaming has been done) var processImages = function(metabook, builddir, options) { @@ -670,6 +687,10 @@ if (val.mime.startsWith('image/svg')) { pp = pp.then(convertSvg); } + // strip EXIF from jpgs + if (val.mime === 'image/jpeg') { + pp = pp.then(convertJpg); + } // rename file if it is not TeX safe. pp = pp.then(function(info) { var safe = info.filename.replace(/[^A-Za-z0-9.:]+/g, '-'); -- To view, visit https://gerrit.wikimedia.org/r/98556 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I33e08508ce117b8843430bd23ac80ebaf321f1ca Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator/latex_renderer Gerrit-Branch: master Gerrit-Owner: Cscott <canan...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits