"PHP GD이미지 base64 img 태그로 변환"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
2번째 줄: 2번째 줄:
;PHP GD이미지 base64 img 태그로 출력
;PHP GD이미지 base64 img 태그로 출력


<syntaxhighlight lang='php'>
<syntaxhighlight lang='php' run>
<?php
<?php
function image2html( $image ) {
function image2html( $image ) {
19번째 줄: 19번째 줄:
echo image2html( $red_box );
echo image2html( $red_box );
</syntaxhighlight>
</syntaxhighlight>
:→ http://example.zetawiki.com/php/gd1.php


==같이 보기==
==같이 보기==

2021년 4월 14일 (수) 16:08 기준 최신판

1 개요[ | ]

PHP GD이미지 base64 img 태그로 출력
<?php
function image2html( $image ) {
	ob_start();
	imagepng( $image );
	$data = ob_get_contents();
	ob_end_clean();
	return "<img src='data:image/png;base64,".base64_encode($data)."'>";
}
$black_box = imagecreate( 100, 200 );
imagecolorallocate( $black_box, 0, 0, 0 );
$red_box = imagecreate( 100, 200 );
imagecolorallocate( $red_box, 255, 0, 0 );

echo image2html( $black_box );
echo image2html( $red_box );

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}