[Tex/LaTex] \includegraphics clipping and trim is squishing image

cropgraphics

Clipping keeps squishing my image.

My command is:

\includegraphics[keepaspectratio=false,clip=true,trim=90px 0 0 0]{blue.jpg}

But I'm getting:

enter image description here

Where the original image is:

unclipped

Why can't I clip or trim an image without squishing? There is a part of an image that I want to cut off without having to go into a photo editor to do it.

Best Answer

It is clearly a bug in the driver for package graphicx:

  • pdftex.def: ok.
  • dvips.def: ok for PostScript images, but clipping is not supported for bitmap images.
  • xetex.def: Clipping is not supported at all.
  • dvipdfm.def: The image is not trimmed, but distorted in the final area.
  • dvipdfmx.def: The whole image is put in the final area without distortion, but empty space is put above the small image.

A remark to keepaspectratio: It has a meaning only if both the width and height are specified. Thus the setting and values of keepaspectratio does not matter here.

There is a solution for dvips.def, dvipdfm.def and dvipdfmx.def if pdfTeX is used as TeX compiler (for DVI mode). Package bmpsize fixes as side effect the defective drivers. And the package improves the bitmap inclusion making separate bounding box files obsolete. The driver xetex.def cannot be fixed this way, because XeTeX misses primitives from pdfTeX (especially \pdffiledump), needed by bmpsize.

\usepackage[dvipdfm]{graphicx}
\usepackage{bmpsize}
Related Question