Friday, November 22, 2024

Brighten an \includeimage image in LaTeX Using decodearray without modifying the file

You can adjust the brightness of \includegraphics images in LaTeX without editing them!

The decodearray option in the graphicx package allows you to modify the appearance of images directly within your document.
This is especially useful if you need to tweak image brightness directly in your document without relying on external image editing tools.
The decodearray feature relies on PDF features supported by modern LaTeX engines  such as LuaLaTeX or XeLaTeX. 

\documentclass{article}
\usepackage{graphicx}
\begin{document}

% Original RGB image
\section*{Original Image}
\includegraphics[width=0.5\textwidth]{example-image.jpg}

% Brightened image using decodearray
\section*{Brightened RGB Image}
\includegraphics[width=0.5\textwidth, decodearray={0.2 0.5   0.2 0.5   0.2 0.5}]{uiskentuie_standing_stone.png}


\end{document}


In the example decodearray={0.2 0.5    0.2 0.5    0.2 0.5} maps the original range [0, 1] for each one of the three RGB channels to a narrower, brighter range [0.2, 0.5].

source: https://tex.stackexchange.com/questions/29227/can-includegraphics-be-used-to-change-an-image-color/150219#150219


No comments:

Post a Comment