图片转base64
<?php /** * Describe: 图片转base64 * 使用方法: php imgtobase64.php path=/www/projects/test/20220623171931.png * Author: ZhaoGuibin * Date: 2022-06-23 */ class ImgToBase64 { static private $instance; private function __construct() { } static public function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; } /** * 获取命令行输入参数 * @return array */ function getClientArgs() { global $argv; array_shift($argv); $args = array(); array_walk($argv, function ($v, $k) use (&$args) { @list($key, $value) = @explode('=', $v); $args[$key] = $value; }); return $args; } /** * 图片转为base64 * @param $img_path * @return string|void */ function imgToBase64($img_path = '') { $img = isset($img_path['path']) ?...