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 | <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>이미지의 크기 및 정보 구하기</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<div>
<?php
require_once 'h.php';
$fileName = __DIR__ . '/test.jpg';
if( !file_exists($fileName) )
{
die('파일이 존재하지 않음');
}
// 이미지 정보를 구함
$imageInfo = getimagesize($fileName);
// 이미지 정보를 표시
echo "<table>";
echo "<tr><td>파일이름</td>";
echo "<td>" . h($fileName) . "</td></tr>";
echo "<tr><td>폭</td>";
echo "<td>" . h($imageInfo[0]) . "</td></tr>";
echo "<tr><td>높이</td>";
echo "<td>" . h($imageInfo[1]) . "</td></tr>";
echo "<tr><td>종류(1:gif, 2:jpg, 3:png, 4:swf, 17:ico 등)</td>";
echo "<td>" . h($imageInfo[2]) . "</td></tr>";
echo "<tr><td><img>태그에서 직접 이용할 수 있는 문자열</td>";
echo "<td>" . h($imageInfo[3]) . "</td></tr>";
if( isset($imageInfo['bits']) )
{
echo "<tr><td>bits</td>";
echo "<td>" . h($imageInfo['bits']) . "</td></tr>";
}
if( isset($imageInfo['channels']) )
{
echo "<tr><td>channels(3:RGB, 4:CMYK)</td>";
echo "<td>" . h($imageInfo['channels']) . "</td></tr>";
}
echo "<tr><td>MIME</td>";
echo "<td>" . h($imageInfo['mime']) . "</td></tr>";
echo "</table>";
$url = './128_display.php?file=' . rawurlencode(basename($fileName));
echo '<p><img src="' . h($url) . '" alt="사진"></p>';
?>
</div>
</body>
</html>
|
2018년 5월 22일 화요일
[PHP예제] 144 이미지의 크기 및 정보 구하기
피드 구독하기:
댓글 (Atom)

댓글 없음:
댓글 쓰기