Supported Versions: PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0
Return information about a string buffer
<?php finfo_buffer( finfo $finfo, string $string, int $flags = FILEINFO_NONE, ?resource $context = null): string|false
<?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()
);
$this->setOutput(new Response(
200,
<?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);
}