This makes colored rectangles if the argument to \includegraphics
is a declared color. In the part
\prop_gset_from_keyval:Nn \g_stork_ig_ratios_prop
{
red=3/4, green=16/9, blue=3/4, orange=3/4, yellow=3/4
}
you set both the known color and the aspect ratio for the corresponding type of image (height/width).
Example of usage. The complicated code could well stay in a separate file that you \input
and when all images are filled in you can remove the \input
line.
\documentclass{article}
\usepackage{graphicx,xcolor}
% to be removed when the document has all the pictures
\NewCommandCopy{\originalincludegraphics}{\includegraphics}
\ExplSyntaxOn
\RenewDocumentCommand{\includegraphics}{O{}m}
{
\stork_ig:nn { #1 } { #2 }
}
\prg_generate_conditional_variant:Nnn \clist_if_in:Nn { Nx } { T,F,TF }
\prop_new:N \g_stork_ig_ratios_prop
\clist_new:N \g_stork_ig_colors_clist
\keys_define:nn { stork/ig }
{
width .dim_set:N = \l_stork_ig_wd_dim,
width .initial:n = 8cm,
unknown .code:n = {},
}
\cs_new_protected:Nn \stork_ig:nn
{
\group_begin:
\clist_if_in:NxTF \g_stork_ig_colors_clist { \tl_to_str:n { #2 } }
{
\keys_set:nn { stork/ig } { #1 }
\stork_ig_fake:n { #2 }
}
{
\originalincludegraphics[#1]{#2}
}
\group_end:
}
\cs_new_protected:Nn \stork_ig_fake:n
{
\textcolor{#1}
{
\rule
{% width
\l_stork_ig_wd_dim
}
{% height
\dim_eval:n { \l_stork_ig_wd_dim * \prop_item:Nn \g_stork_ig_ratios_prop { #1 } }
}
}
}
% set the known colors
\prop_gset_from_keyval:Nn \g_stork_ig_ratios_prop
{
red=3/4, green=16/9, blue=3/4, orange=3/4, yellow=3/4
}
\prop_map_inline:Nn \g_stork_ig_ratios_prop
{
\clist_gput_right:Nn \g_stork_ig_colors_clist { #1 }
}
\ExplSyntaxOff
% end of temporary code
\begin{document}
\includegraphics[width=0.4\textwidth]{red}
\includegraphics[width=0.2\textwidth]{green}
\includegraphics[width=0.2\textwidth]{orange}
\includegraphics[width=0.4\textwidth]{example-image}
\end{document}
If you don't want fixed aspect ratios for the various colors, you can modify the code to calls such as
\includegraphics[width=0.3\textwidth]{red:3/4}
where the aspect ratio is always height/width, but a single integer is allowed (with /1
implied).
\documentclass{article}
\usepackage{graphicx,xcolor}
% to be removed when the document has all the pictures
\NewCommandCopy{\originalincludegraphics}{\includegraphics}
\ExplSyntaxOn
\RenewDocumentCommand{\includegraphics}{O{}m}
{
\stork_ig:nn { #1 } { #2 }
}
\prg_generate_conditional_variant:Nnn \clist_if_in:Nn { Nx } { T,F,TF }
\cs_generate_variant:Nn \seq_set_split:Nnn { NV }
\seq_new:N \l_stork_ig_name_seq
\clist_new:N \g_stork_ig_colors_clist
\keys_define:nn { stork/ig }
{
width .dim_set:N = \l_stork_ig_wd_dim,
width .initial:n = 8cm,
unknown .code:n = {},
}
\cs_new_protected:Nn \stork_ig:nn
{
\group_begin:
\seq_set_split:NVn \l_stork_ig_name_seq \c_colon_str { #2 }
\clist_if_in:NxTF \g_stork_ig_colors_clist { \seq_item:Nn \l_stork_ig_name_seq { 1 } }
{
\keys_set:nn { stork/ig } { #1 }
\stork_ig_fake:xx
{ \seq_item:Nn \l_stork_ig_name_seq { 1 } }
{ \seq_item:Nn \l_stork_ig_name_seq { 2 } }
}
{
\originalincludegraphics[#1]{#2}
}
\group_end:
}
\cs_new_protected:Nn \stork_ig_fake:nn
{
\textcolor{ #1 }
{
\rule
{% width
\l_stork_ig_wd_dim
}
{% height
\__stork_ig_height:n { #2 }
}
}
}
\cs_generate_variant:Nn \stork_ig_fake:nn { xx }
\cs_new:Nn \__stork_ig_height:n
{
\dim_eval:n
{
\l_stork_ig_wd_dim
*
\tl_if_blank:nTF { #1 } { 3/4 } { #1 }
}
}
% set the known colors
\clist_gset:Nn \g_stork_ig_colors_clist { red, green, blue, orange, yellow }
\ExplSyntaxOff
% end of temporary code
\begin{document}
\includegraphics[width=0.4\textwidth]{red:3/4}
\includegraphics[width=0.2\textwidth]{green:16/11}
\includegraphics[width=0.2\textwidth]{orange:1}
\includegraphics[width=0.4\textwidth]{example-image}
\end{document}