GD 라이브러리를 이용하여 이미지를 축소 확대 시키는 클래스 입니다.
갤러리 프로그램에서 별도의 프로그램구동없이 썸네일을 만들어 주어야 할때
유용하게 쓰일수 있을거 같습니다.
==============
라이센스
==============
GNU GPL
==============
설치환경
==============
GD 라이브러리
=============
설 치
=============
파일을 업로드 하는것만으로 설치작업은 완료됩니다.
사용법은 아래와 같습니다.
include("../class.Thumbnail.php"); <-- 썸네일을 만드는 클래스파일 경로지정
$tn_image = new Thumbnail("sample.gif", 0, 0, 25); <-- 객체 생성
sample.gif : 이미지 파일명
0 : 최대 썸네일 폭 (옵션)
0 : 최대 썸네일 길이 (옵션)
25 : 퍼센트 (옵션)
$tn_image->show(); <-- 이미지 파일 출력
==============
주 의
==============
본 클래스를 사용하기 위해서는 GD 라이브러리가 사용가능 해야 하며
jpg,gif,png 의 이미지 화일중 GD 에서 지원하는 포멧형식만 사용가능
합니다.
확인방법은 아래 줄을 새파일에 적은후에 웹브라우저로 보면 PHP 가
지원하는 모듈을 볼수 있습니다.
==============
소 스
==============
소스는 다운로드 받으면 동일한 소스와 예제파일이 있습니다.
/*
* class.Thumbnail.php
*
* Copyright (C) 2001 Hidayet Dogan (hdogan@bilcag.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
class Thumbnail {
var $errmsg = "";
var $error = false;
var $format = "";
var $file = "";
var $max_width = 0;
var $max_height = 0;
var $percent = 0;
function Thumbnail($file, $max_width = 0, $max_height = 0, $percent = 0) {
if (!file_exists($file)) {
$this->errmsg = "File doesn``t exists";
$this->error = true;
}
else if (!is_readable($file)) {
$this->errmsg = "File is not readable";
$this->error = true;
}