# Show actual size of image with \includegraphics

Problem:

I'm trying to display a photo that is 299 x 153 pixels (300 dpi) in a document but it gets "shrinked" for some reason.

The actual photo:

Minimal Working Example (MWE):

\documentclass[export]{article}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{makeidx}
\usepackage{multicol}
\usepackage{ragged2e}
\usepackage{fancyvrb}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{tikz}
\usepackage{makecell}
\usepackage{xparse}
\usepackage{cellspace,tabularx}

\let\oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[2][]{\oldincludegraphics[valign=c,#1]{#2}}

\begin{document}

\begin{figure}[tbh]
\caption{Text.}
\label{fig:phpma-dropdbop}
\end{figure}

\end{document}


The output:

Desired outcome:

To get the actual size of the photo to output in the .tex document as indicated by the first photo.

• Does \includegraphics[width=299px,height=153px]{phpmyadmin-dropdatabase-op.png} solve this? – cauchy42 Sep 1 '15 at 6:58
• @cauchy42 It seems to fix it in the MWE but not in my template. It gets "wrangled". See updated MWE. – kexxcream Sep 1 '15 at 7:03
• You redefine \includegraphics with the first argument being optional, but call it only with its second argument. As you don't specify the first (which would be the width, I suppose), you have no control. Calling \includegraphics[width=233px]{phpmyadmin-dropdatabase-op.png} does what you want. But then, you need not redefine the macro, as the original \includegraphics has much more capabilities. – cauchy42 Sep 1 '15 at 7:27
• \newlength{\pixel} \setlength{\pixel}{\dimexpr 1in/300} will give you 300dpi. [width=299\pixel,height=153\pixel] – John Kormylo Sep 1 '15 at 16:13

Use:

\includegraphics[scale=1]{phpmyadmin-dropdatabase-op.png}


to get the actual size, if you want to fill in the width of the page, use:

\includegraphics[width=\textwidth]{phpmyadmin-dropdatabase-op.png}


if you want to limit the height in some way, use something like:

\includegraphics[height=0.5\textheight]{phpmyadmin-dropdatabase-op.png}


or

\includegraphics[height=10cm]{phpmyadmin-dropdatabase-op.png}