imagecreatefromstring
Intervention/image
Supported Versions: PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8
Create a new image from the image stream in the string
imagecreatefromstring
(
string $data
):
GdImage
|
false
case
'image/pjpeg'
:
$core
= @
imagecreatefromjpeg
(
$path
);
if (!
$core
) {
$core
= @
imagecreatefromstring
(
file_get_contents
(
$path
));
}
break;
src/Intervention/Image/Gd/Decoder.php
public function
initFromBinary
(
$binary
)
{
$resource
= @
imagecreatefromstring
(
$binary
);
if (
$resource
===
false
) {
throw new
NotReadableException
(
src/Intervention/Image/Gd/Decoder.php
{
$img
=
$this
->
manager
()->
make
(
'tests/images/trim.png'
);
$img
->
encode
();
$this
->
assertInternalType
(
'resource'
,
imagecreatefromstring
(
$img
->
encoded
));
}
public function
testEncodeJpeg
()
tests/GdSystemTest.php
{
$img
=
$this
->
manager
()->
make
(
'tests/images/trim.png'
);
$img
->
encode
(
'jpg'
);
$this
->
assertInternalType
(
'resource'
,
imagecreatefromstring
(
$img
->
encoded
));
}
public function
testEncodeGif
()
tests/GdSystemTest.php
{
$img
=
$this
->
manager
()->
make
(
'tests/images/trim.png'
);
$img
->
encode
(
'gif'
);
$this
->
assertInternalType
(
'resource'
,
imagecreatefromstring
(
$img
->
encoded
));
}
public function
testEncodeWebp
()
tests/GdSystemTest.php