gifの使用色一覧を返すクラス

前に、苦戦して作ってたものですが
かなーりすっきりしました。
動作確認・・・できてません・・・(ぇ
 

<?php

class ColorList {

    function __construct() {
    }
// 色数
    function getColorCount($img_path){
      $imgobj = imagecreatefromgif($img_path);
      $count = imagecolorstotal($imgobj);
      return $count;
    }
// カラーインデックスIDとカラーコードの配列
    function getColorArray($img_path){
      $ret = array();
      $imgobj = imagecreatefromgif($img_path);
      list($width, $height, $type, $attr) = getimagesize($img_path);
      $count = imagecolorstotal($imgobj);
      for($i=0; $i<$count; $i++){
        $rgbarray = imagecolorsforindex($imgobj,$i);
        $color = sprintf("%2x%2x%2x",$rgbarray["red"],$rgbarray["green"],$rgbarray["blue"]);
        $ret[$i] = $color;
      }
      return $ret;
    }
}

?>