$image_text_max_height && intval($image_text_max_height)!=0){$olheight=$image_text_max_height;} # Locate imagemagick. $convert_fullpath = get_utility_path("im-convert"); if (!$convert_fullpath) { exit("Could not find ImageMagick 'convert' utility at location '$imagemagick_path'"); } $tmpolfile= get_temp_dir() . "/" . $ref . "_image_text_" . uniqid() . "." . $ext; $createolcommand = $convert_fullpath . " -background '#000' -fill white -gravity %%POSITION%% -font %%FONT%% -size %%WIDTHHEIGHT%% caption:%%CAPTION%% %%TMPOLFILE%%"; $createolparams = [ "%%POSITION%%" => new CommandPlaceholderArg($image_text_position,fn($val): bool => in_array($val, ["east","west","center"])), "%%FONT%%" => new CommandPlaceholderArg($image_text_font, fn($val): bool => preg_match('/^[a-zA-Z0-9\#\s\-]*$/', $val) === 1), "%%WIDTHHEIGHT%%" => (int) $width . "x" . (int) $olheight, "%%CAPTION%%" => new CommandPlaceholderArg($overlaytext, 'is_string'), "%%TMPOLFILE%%" => $tmpolfile, ]; run_command($createolcommand, false, $createolparams); $newdlfile = get_temp_dir() . "/" . $ref . "_image_text_result_" . uniqid() . "." . $ext; if($image_text_banner_position == "bottom") { $convertcommand = $convert_fullpath . " %%PATH%% %%TMPOLFILE%% -append %%NEWDLFILE%%"; } else { $convertcommand = $convert_fullpath . " %%TMPOLFILE%% %%PATH%% -append %%NEWDLFILE%%"; } $convertparams = [ "%%PATH%%" => new CommandPlaceholderArg($path, 'is_valid_rs_path'), "%%TMPOLFILE%%" => new CommandPlaceholderArg($tmpolfile, 'is_safe_basename'), "%%NEWDLFILE%%" => new CommandPlaceholderArg($newdlfile, 'is_safe_basename'), ]; run_command($convertcommand, false, $convertparams); $oldpath = $path; if ($path != $tmpfile) { // If this is not a temporary file having metadata written then move it to the filestore for future use rename($newdlfile, $image_text_saved_file); $path = $image_text_saved_file; } else { $path = $newdlfile; } try_unlink($tmpolfile); if (strpos(get_temp_dir(), $oldpath) === 0) { try_unlink($oldpath); } return true; }