Here's a simple "save as image" function:
saveImage[image_Graphics, format_String: "png", resolution_Real: 200] := Export[
TemplateApply[
"`basename`.`format`", <|
"basename" -> SymbolName[Unevaluated[image]],
"format" -> format|
>]
, image
, ImageResolution -> resolution
];
However, I can't make it hold the image name:
myImage = Plot[x, {x, 0, 1}]
saveImage@myImage (* evaluates image to be a Graphics object instead of the symbol *)
What do I do wrong?
HoldFirst
but then you need to changeimage_Graphics
as you expect_Symbol
. $\endgroup$ – Kuba♦ May 21 '18 at 20:56