FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-src/ext/gd/tests/createfromstring.phpt at master · EndlessCoding/php-src · GitHub
EndlessCoding
/
php-src
Public
forked from
php/php-src
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
php-src
/
ext
/
gd
/
tests
/
createfromstring.phpt
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (52 loc) · 1.57 KB
Breadcrumbs
php-src
/
ext
/
gd
/
tests
/
createfromstring.phpt
Copy path
File metadata and controls
64 lines (52 loc) · 1.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--TEST--
imagecreatefromstring
--SKIPIF--
<?php
if
(!
function_exists
(
'
imagecreatefromstring
'
))
die
(
"
skip gd extension not available
\n"
);
if
(!
function_exists
(
'
imagepng
'
))
die
(
"
skip no imagpng()
\n"
);
?>
--FILE--
<?php
$
dir
=
dirname
(
__FILE__
);
$
im
=
imagecreatetruecolor
(
5
,
5
);
imagefill
(
$
im
,
0
,
0
,
0xffffff
);
imagesetpixel
(
$
im
,
3
,
3
,
0x0
);
imagepng
(
$
im
,
$
dir
.
'
/tc.png
'
);
$
im_string
=
file_get_contents
(
dirname
(
__FILE__
) .
'
/tc.png
'
);
$
im
=
imagecreatefromstring
(
$
im_string
);
echo
'
createfromstring truecolor png:
'
;
if
(
imagecolorat
(
$
im
,
3
,
3
) !=
0x0
) {
echo
'
failed
'
;
}
else
{
echo
'
ok
'
;
}
echo
"\n"
;
unlink
(
$
dir
.
'
/tc.png
'
);
$
im
=
imagecreate
(
5
,
5
);
$
c1
=
imagecolorallocate
(
$
im
,
255
,
255
,
255
);
$
c2
=
imagecolorallocate
(
$
im
,
255
,
0
,
0
);
imagefill
(
$
im
,
0
,
0
,
$
c1
);
imagesetpixel
(
$
im
,
3
,
3
,
$
c2
);
imagepng
(
$
im
,
$
dir
.
'
/p.png
'
);
$
im_string
=
file_get_contents
(
dirname
(
__FILE__
) .
'
/p.png
'
);
$
im
=
imagecreatefromstring
(
$
im_string
);
echo
'
createfromstring palette png:
'
;
$
c
=
imagecolorsforindex
(
$
im
,
imagecolorat
(
$
im
,
3
,
3
));
$
failed
=
false
;
if
(
$
c
[
'
red
'
] !=
255
||
$
c
[
'
green
'
] !=
0
||
$
c
[
'
blue
'
] !=
0
) {
echo
'
failed
'
;
}
else
{
echo
'
ok
'
;
}
echo
"\n"
;
unlink
(
$
dir
.
'
/p.png
'
);
//empty string
$
im
=
imagecreatefromstring
(
''
);
//random string > 8
$
im
=
imagecreatefromstring
(
'
asdf jklp
'
);
?>
--EXPECTF--
createfromstring truecolor png: ok
createfromstring palette png: ok
Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d
Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d
Back
|
FazBrowse Home
|
New Git URL