R

GD 를 이용한 테이블 포토 (imagecolorat)

저녁에 문득 생각나서 ..ㅋㅋ
이미지의 좌표별 색상값을 뽑아 내어 테이블로 똑같은 이미지를 만들수 있지 않을까하는 생각에  시도해보았습니다.
아래 이미지는 결과물입니다.
익스에서는 제대로 된값이 나오질 않더군요..^^
조그만 이미지 도 제대로 값을 출력해내지 못하고 있네요.
아래 이미지는 파폭에서 600 400 픽셀 이미지로 테스트 한 결과 입니다.
파폭도 완벽하게 출력해내지는 못합니다.
위쪽 파란색 테두리의 이미지가 원본이며 아래 이미지는 테이블로 만들어진 이미지 입니다.



아하 php 쏘스 입니다.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<?
 
$imgdir = "p.jpg"; // 이미지 경로를 적어주시면됩니다.

list($width, $height, $type, $attr) = getimagesize($imgdir); // 이미지 사이즈 및 타입을 구함.
$im = imagecreatefromjpeg($imgdir); 
 
function getimgcolorat($x, $y){
 global $type, $im;
 
 $rgb = imagecolorat($im, $x, $y); // 이미지에서 좌표값의 색상을 뽑아온다.
 //unset($im);
 return dechex($rgb);
 unset($rgb);
}
 
 $color = array();
 $c = 0;
 for($y=0; $y<$height; $y++){
  for($x=0; $x<$width; $x++){ 
   $imgcolor = getimgcolorat($x, $y);
   
   $key = $x.$y;
   if($data[$imgcolor]){
    $sellcolor[$key] = $data[$imgcolor];
   }else{
    $color[$c] = $imgcolor;
    $data[$imgcolor] = $c;
    $sellcolor[$key] = $c;
    $c++;
   }
   unset($imgcolor);
  }
 }
 unset($data);
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>Untitled Document</title>
<style type="text/css">
<!--
.ts {
 width: 1px;
 height: 1px;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="10" cellpadding="10">
  <tr>
    <td bgcolor="#0099FF"><img src="<?=$imgdir?>" width="<?=$width?>" height="<?=$height?>"></td>
  </tr>
  <tr>
    <td>

   
    <table width="<?=$width?>" border="0" cellspacing="0" cellpadding="0">
    <?
 for($y=0; $y<$height; $y++){
  echo "<tr>";
  for($x=0; $x<$width; $x++){ 
   $key = $x.$y;
   $bgcolor = $color[$sellcolor[$key]];
   echo "<td bgcolor=\"#{$bgcolor}\" class=\"ts\"></td>";
  }
  echo "</tr>";
 }
 
 ?>
    </table>
   
    </td>
  </tr>
</table>
</body>
</html>

[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|

댓글 3개

성능 테스트 용으로 좋겠습니다. ^^
멋지네요.. ^^

이미지 복제 시간은 많이 안 걸리나요?
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
08-10-30 조회 2,713
08-10-30 조회 2,812
08-10-20 조회 2,541
08-10-11 조회 2,447
08-09-20 조회 4,187
08-09-20 조회 2,858
08-09-18 조회 2,743
08-09-18 조회 3,438
08-09-17 조회 3,303
08-09-05 조회 4,640
08-09-03 조회 2,775
08-08-18 조회 2,900
08-08-17 조회 2,639
08-08-13 조회 3,420
08-07-30 조회 3,483
08-07-28 조회 4,359
08-07-22 조회 5,589
08-07-22 조회 4,076
08-07-10 조회 3,045
08-07-08 조회 3,107
08-06-30 조회 3,867
08-06-30 조회 3,350
08-06-30 조회 3,668
08-06-14 조회 2,741
08-06-11 조회 7,103
08-06-05 조회 3,317
08-05-20 조회 4,830
08-05-13 조회 4,172
08-05-08 조회 3,125
08-05-08 조회 5,280
08-04-25 조회 4,075
08-04-22 조회 4,544
08-04-21 조회 3,188
08-04-17 조회 2,570
08-04-17 조회 2,969
08-04-17 조회 2,268
08-04-17 조회 5,236
08-04-17 조회 4,555
08-04-17 조회 4,550
08-04-17 조회 3,333
08-04-17 조회 3,157
08-04-17 조회 3,642
08-04-17 조회 5,004
08-04-17 조회 5,150
08-04-17 조회 3,357
08-04-04 조회 4,619
08-04-04 조회 2,849
08-04-04 조회 2,591
08-04-04 조회 2,818
08-04-04 조회 2,552
08-04-04 조회 2,796
08-04-03 조회 2,681
08-04-03 조회 2,753
08-04-02 조회 3,064
08-04-02 조회 3,220
08-03-31 조회 3,108
08-03-26 조회 4,286
08-03-11 조회 2,973
08-03-11 조회 2,383
08-03-11 조회 2,395
08-03-07 조회 4,230
08-03-07 조회 3,323
08-03-06 조회 4,771
08-03-04 조회 3,401
08-02-19 조회 3,797
08-02-03 조회 3,420
08-01-18 조회 4,006
08-01-15 조회 3,456
08-01-12 조회 4,301
08-01-12 조회 3,870
08-01-12 조회 3,825
07-12-24 조회 3,118
07-11-30 조회 3,961
07-11-08 조회 5,019
07-11-06 조회 3,871
07-10-26 조회 5,013
07-10-24 조회 4,199
07-10-22 조회 3,585
07-10-19 조회 4,771
07-10-09 조회 4,904
07-10-09 조회 6,769
07-10-05 조회 3,104
07-10-05 조회 4,041
07-10-03 조회 7,548
07-10-03 조회 3,595
07-10-03 조회 2,945
07-10-03 조회 2,873
07-09-28 조회 4,716
07-09-27 조회 3,781
07-09-27 조회 3,230
07-09-13 조회 3,383
07-08-28 조회 3,463
07-08-04 조회 4,851
07-08-01 조회 5,545
07-08-01 조회 4,948
07-07-30 조회 5,470
07-07-29 조회 3,614
07-07-21 조회 3,434
07-07-18 조회 5,393
07-07-16 조회 3,188