- writefile($fn, $config{destdir}, $png, 1);
+ if (! $params{preview}) {
+ writefile($fn, $config{destdir}, $png, 1);
+ }
+ else {
+ # in preview mode, embed the image in a data uri
+ # to avoid temp file clutter
+ eval q{use MIME::Base64};
+ error($@) if $@;
+ return "<img src=\"data:image/png;base64,".
+ encode_base64($png)."\" />";
+ }