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