Supported Versions: PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
Reads entire file into a string
<?php file_get_contents( string $filename, bool $use_include_path = false, ?resource $context = null, int $offset = 0, ?int $length = null): string|false
<?php $context = stream_context_create($options);
if ($data = @file_get_contents($url, false, $context)) {
return $this->initFromBinary($data);
}
<?php case 'image/pjpeg':
$core = @imagecreatefromjpeg($path);
if (!$core) {
$core= @imagecreatefromstring(file_get_contents($path));
}
break;
<?php } else {
$content = file_get_contents($image_path);
}
<?php public function testIsBinary()
{
$source = $this->getTestDecoder(file_get_contents(__DIR__.'/images/test.jpg'));
$this->assertTrue($source->isBinary());
$source = $this->getTestDecoder(null);
<?php public function testMakeFromString()
{
$str = file_get_contents('tests/images/circle.png');
$img = $this->manager()->make($str);
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertInternalType('resource', $img->getCore());
<?php public function testInsertBinary()
{
$data = file_get_contents('tests/images/tile.png');
$img = $this->manager()->make('tests/images/trim.png');
$img->insert($data);
$this->assertInstanceOf('Intervention\Image\Image', $img);
<?php public function testFillImageWithBinary()
{
$data = file_get_contents('tests/images/tile.png');
$img = $this->manager()->make('tests/images/trim.png');
$img->fill($data, 0, 0);
$this->assertColorAtPosition('#b4e000', $img, 0, 0);
<?php public function testMakeFromString()
{
$str = file_get_contents('tests/images/circle.png');
$img = $this->manager()->make($str);
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertInstanceOf('Imagick', $img->getCore());
<?php public function testInsertBinary()
{
$data = file_get_contents('tests/images/tile.png');
$img = $this->manager()->make('tests/images/trim.png');
$img->insert($data);
$this->assertInstanceOf('Intervention\Image\Image', $img);
<?php public function testFillImageWithBinary()
{
$data = file_get_contents('tests/images/tile.png');
$img = $this->manager()->make('tests/images/trim.png');
$img->fill($data, 0, 0);
$this->assertColorAtPosition('#b4e000', $img, 0, 0);