得到图片的信息

@param $imgfile 文件文件名
@return mixed
514980
public static function getInfo($imgfile)
    {
        $imageInfo = getimagesize($imgfile);
        if ($imageInfo !== false) {
            $imageType = strtolower(substr(image_type_to_extension($imageInfo[2]), 1));
            $imageSize = filesize($imgfile);
            $info      = array(
                "width"  => $imageInfo[0],
                "height" => $imageInfo[1],
                "type"   => $imageType,
                "size"   => $imageSize,
                "mime"   => $imageInfo['mime'],
            );
            return $info;
        } else {
            return false;
        }
    }
410575
protected function getDirectoryRelativeToFile(string $configFile, ?string $directory = null): ?string
    {
        if (!$directory) {
            return null;
        }

        $path = realpath(dirname($configFile) . '/' . $directory);

        if (false !== $path) {
            return $path;
        }

        return $directory;
    }
430097
public function getSplFileInfo(): \SplFileInfo
    {
        if (null !== $this->splFileInfo && $this->path === $this->splFileInfo->getRealPath()) {
            return $this->splFileInfo;
        }
        $this->assertExists();

        return $this->createSplFileInfo();
    }
1126371
public function getFileContents($sFile)
    {
        $sContents = null;
        if (file_exists($sFile) && is_readable($sFile)) {
            $sContents = file_get_contents($sFile);
        }

        return $sContents;
    }
1114309
public static function getFileMimeType($file)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        if ($finfo) {
            $mime_type = finfo_file($finfo, $file);
            finfo_close($finfo);
            return $mime_type;
        }
        return false;
    }
532793
public function getMimeType(){
		if( function_exists( 'finfo_open' ) ){
			$magicFile	= ini_get( 'mime_magic.magicfile' );
//			$magicFile	= str_replace( "\\", "/", $magicFile );
//			$magicFile	= preg_replace( "@\.mime$@", "", $magicFile );
			$fileInfo	= finfo_open( FILEINFO_MIME_TYPE, $magicFile );
			$mimeType	= finfo_file( $fileInfo, realpath( $this->pathName ) );
			finfo_close( $fileInfo );
			return $mimeType;
		}
		else if( substr( PHP_OS, 0, 3 ) != "WIN" ){
			$command	= 'file -b --mime-type '.escapeshellarg( $this->pathName );
			return trim( exec( $command ) );
		}
		else if( function_exists( 'mime_content_type' ) ){
			if( $mimeType = mime_content_type( $this->pathName ) )
				return $mimeType;
		}
		throw new RuntimeException( 'PHP extension Fileinfo is missing' );
	}
882548
private function loadConfigFile($configFile)
    {
        if ($this->useCache) {
            if (function_exists('apc_fetch')) {
                $config = apc_fetch($configFile);
            } elseif (function_exists('apcu_fetch')) {
                $config = apcu_fetch($configFile);
            }

            if (!empty($config)) {
                return $config;
            }
        }

        if (!is_readable($configFile)) {
            throw new FileNotFoundException("File $configFile could not be found.");
        }

        try {
            $config = $this->parser->parse(file_get_contents($configFile));
        } catch (ParseException $e) {
            $line = $e->getParsedLine();
            throw new InvalidConfigFileException(
                "File $configFile does not have a valid format (line $line)"
            );
        }

        if ($this->useCache) {
            if (function_exists('apc_store')) {
                apc_store($configFile, $config);
            } elseif (function_exists('apcu_store')) {
                apcu_store($configFile, $config);
            }
        }

        return $config;
    }
227515
public static function getMimeTypeByFile(string $file)
    {
        if (!\is_file($file) || !\class_exists('\finfo', false)) {
            return null;
        }

        try {
            $finfo = new \finfo(FILEINFO_MIME_TYPE);

            return $finfo->file($file) ?: null;
            // @codeCoverageIgnoreStart
        } catch (\ErrorException $e) {
            // This is caused by an array to string conversion error.
            return null;
        }
    }
1215804
public function getMimeType()
    {
        if ($this->exists()) {
            $finfo = new \finfo(FILEINFO_MIME_TYPE | FILEINFO_PRESERVE_ATIME);
            $mime = $finfo->file($this->getRealPath());
            return $mime;
        }
        return null;
    }
860550
public function getMimeType(\SplFileInfo $file)
    {
        $fileInfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_file($fileInfo, $file->getPathname());
        finfo_close($fileInfo);

        return $mimeType;
    }
969207
protected function setImage($keyImg, $imgFile)
    {
        // If it's false or null we have to remove it from the server
        if (!$imgFile || is_null($imgFile)) {
            return $this->removeImage($keyImg);
        }
        if (strpos($imgFile['name'], '.php') !== false) {
            throw new \Exception('For security reasons, the extension ".php" cannot be in your file name.');
        }
        $avatar = wp_handle_upload($_FILES[$keyImg],
            [
                'mimes' => [
                    'jpg|jpeg|jpe' => 'image/jpeg',
                    'gif' => 'image/gif',
                    'png' => 'image/png',
                ],
                'test_form' => false,
                'unique_filename_callback' => function ($dir, $name, $ext) use ($keyImg) {
                    $name = $base_name = sanitize_file_name($this->user_login . '_' . $keyImg);
                    $number = 1;
                    while (file_exists($dir . "/$name$ext")) {
                        $name = $base_name . '_' . $number;
                        $number++;
                    }
                    return $name . $ext;
                },
            ]);
        // Remove the last image
        $this->removeImage($keyImg);

        $metaValue = [];

        $url_or_media_id = $avatar['url'];
        // Set the new image
        if (is_int($url_or_media_id)) {
            $metaValue['media_id'] = $url_or_media_id;
            $url_or_media_id = wp_get_attachment_url($url_or_media_id);
        }
        $metaValue['full'] = $url_or_media_id;
        return update_user_meta($this->ID, $keyImg, $metaValue);
    }
1050207
public function get_imageinfo(stored_file $file) {
        if (!$this->is_image_from_storedfile($file)) {
            return false;
        }

        // Whilst get_imageinfo_from_path can use remote paths, it must download the entire file first.
        // It is more efficient to use a local file when possible.
        return $this->get_imageinfo_from_path($this->get_local_path_from_storedfile($file, true));
    }
426943
public function getMimeType($file){

        if(function_exists('finfo_open')) {
            $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
            $info = finfo_open($const);
            if($info && ($result = finfo_file($info,$file,$const)) !== false){
                finfo_close($info);
                return $result;
            }//if
        }//if

        if(function_exists('mime_content_type') && ($result = mime_content_type($file)) !== false) {
            return $result;
        }//if

    }
206585
public function readProjectConfigFile($dir, $configFile)
    {
        $result = null;
        $filename = $dir . '/' . $this->config->get('service.project_config_dir') . '/' . $configFile;
        if (file_exists($filename)) {
            $parser = new Parser();
            $result = $parser->parse(file_get_contents($filename));
        }

        return $result;
    }
352409
static function verifycode_imagick($img_width = 80, $img_height = 30, $addRandomLines = true, $swirl = true)
    {
        $fontSize = 24;

        /* imagick对象 */
        $Imagick = new \Imagick();

         /* 背景对象 */
        $bg = new \ImagickPixel();

        /* Set the pixel color to white */
        $bg->setColor('rgb(235,235,235)');

        /* 画刷 */
        $ImagickDraw = new \ImagickDraw();

        if (is_file(self::$verifyCodeFontFile))
        {
            $ImagickDraw->setFont(self::$verifyCodeFontFile);
        }

        $ImagickDraw->setFontSize($fontSize);
        $ImagickDraw->setFillColor('black');

        $code = strtoupper(RandomKey::string(self::$verifyCodeLength));

        /* Create new empty image */
        $Imagick->newImage($img_width, $img_height, $bg);

        /* Write the text on the image */
        $Imagick->annotateImage($ImagickDraw, 4, 20, 0, $code);

        /* 变形 */
        if ($swirl)
        {
            $Imagick->swirlImage(10);
        }

        /* 随即线条 */
        if ($addRandomLines)
        {
            $ImagickDraw->line(rand(0, 70), rand(0, 30), rand(0, 70), rand(0, 30));
            $ImagickDraw->line(rand(0, 70), rand(0, 30), rand(0, 70), rand(0, 30));
            $ImagickDraw->line(rand(0, 70), rand(0, 30), rand(0, 70), rand(0, 30));
            $ImagickDraw->line(rand(0, 70), rand(0, 30), rand(0, 70), rand(0, 30));
            $ImagickDraw->line(rand(0, 70), rand(0, 30), rand(0, 70), rand(0, 30));
        }

        /* Draw the ImagickDraw object contents to the image. */
        $Imagick->drawImage($ImagickDraw);

        /* Give the image a format */
        $Imagick->setImageFormat('png');

        /* Send headers and output the image */
        return array('image' => $Imagick->getImageBlob(), 'code' => $code);
    }
590605
protected function getImageInfo($file)
	{
		$imageInfo = getimagesize($file);

		if($imageInfo === false)
		{
			throw new RuntimeException(vsprintf('Unable to process the image [ %s ].', [$file]));
		}

		return $imageInfo;
	}
1209352
public function uploadimg($file)
    {
        if (!$file) {
            $this->setError('参数缺失');

            return false;
        }

        if (!file_exists($file)) {
            $this->setError('文件路径不正确');

            return false;
        }

        $data          = [];
        $data['media'] = '@' . realpath($file);

        $node = 'uploadimg';

        $res = $this->_post($node, $data, false);

        return $res;
    }