Supported Versions: PHP >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0
Create a new finfo instance
<?php finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): finfo|false
<?php public function mimeType($path)
{
return finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
}
<?php public function isBinary()
{
if (is_string($this->data)) {
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->data);
return (substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty');
}
<?php $stream = $image->stream($format, $quality);
$mimetype = finfo_buffer(
finfo_open(FILEINFO_MIME_TYPE),
$image->getEncoded()
);
<?php $this->filename = array_key_exists('filename', $info) ? $info['filename'] : null;
if (file_exists($path) && is_file($path)) {
$this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
}
return $this;
<?php }
$mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
switch (strtolower($mime)) {
<?php }
$image = $this->initFromGdResource($resource);
$image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
return $image;
}
<?php }
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
return new IlluminateResponse($content, 200, [
<?php $image = $this->initFromImagick($core);
$image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
return $image;
}
<?php {
$this->image->encode($this->format, $this->quality);
$data = $this->image->getEncoded();
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data);
$length = strlen($data);
if (function_exists('app') && is_a($app = app(), 'Illuminate\Foundation\Application')) {
<?php {
$img = $this->manager()->make('tests/images/trim.png');
$img->encode();
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $img->encoded);
$this->assertEquals('image/png', $mime);
}
<?php {
$img = $this->manager()->make('tests/images/trim.png');
$img->encode('jpg');
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $img->encoded);
$this->assertEquals('image/jpeg', $mime);
}
<?php {
$img = $this->manager()->make('tests/images/trim.png');
$img->encode('gif');
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $img->encoded);
$this->assertEquals('image/gif', $mime);
}