½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
happycgi
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > PHP > PHP ¼Ò½ºÃ¢°í > À¥ À¯Æ¿¸®Æ¼ > ½æ³×ÀÏ »ý¼ºÅ¬·¡½º »ó¼¼Á¤º¸
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
javascript
PHP
HTML
ASP
mysql
CSS
Mobile
image
jquery
slide
¸Þ´º
�޴�
2023
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
½æ³×ÀÏ »ý¼ºÅ¬·¡½º
¼Ò½ºÅë°èÁ¤º¸ ¿À·ù½Å°í ¹× ¹®ÀÇ
ÇØÇÇÆÀ
³×ƼÁð
Æ®À§ÅÍ·Î º¸³»±â ÆäÀ̽ººÏÀ¸·Î º¸³»±â
¼Ò½ººÐ·ù À¥ À¯Æ¿¸®Æ¼
´Ù¿î·Îµå Ƚ¼ö 727 ȸ
°£´Ü¼³¸í class.Thumbnail.php (½æ³×ÀÏ »ý¼ºÅ¬·¡½º) 1.0
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
¼Ò½º´Ù¿î·Îµå µ¥¸ð ¹Ì¸®º¸±â°¡ ¾ø½À´Ï´Ù ½ºÅ©·¦Çϱâ
==============
¼Ò °³ (INTRO)
==============

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;
}

if (strstr(strtolower($file), ".gif"))
$this->format = "GIF";
else if (strstr(strtolower($file), ".jpg") ||
strstr(strtolower($file), ".jpeg"))
$this->format = "JPEG";
else if (strstr(strtolower($file), ".png"))
$this->format = "PNG";
else {
$this->errmsg = "Unknown file format";
$this->error = true;
}

if ($max_width == 0 && $max_height == 0 && $percent == 0)
$percent = 100;

$this->max_width = $max_width;
$this->max_height = $max_height;
$this->percent = $percent;
$this->file = $file;
}

function calc_width($width, $height) {
$new_width = $this->max_width;
$new_wp = (100 * $new_width) / $width;
$new_height = ($height * $new_wp) / 100;
return array($new_width, $new_height);
}

function calc_height($width, $height) {
$new_height = $this->max_height;
$new_hp = (100 * $new_height) / $height;
$new_width = ($width * $new_hp) / 100;
return array($new_width, $new_height);
}

function calc_percent($width, $height) {
$new_width = ($width * $this->percent) / 100;
$new_height = ($height * $this->percent) / 100;
return array($new_width, $new_height);
}

function return_value($array) {
$array[0] = intval($array[0]);
$array[1] = intval($array[1]);
return $array;
}

function calc_image_size($width, $height) {
$new_size = array($width, $height);

if ($this->max_width > 0) {
$new_size = $this->calc_width($width, $height);

if ($this->max_height > 0) {
if ($new_size[1] > $this->max_height)
$new_size = $this->calc_height($new_size[0], $new_size[1]);
}

return $this->return_value($new_size);
}

if ($this->max_height > 0) {
$new_size = $this->calc_height($width, $height);
return $this->return_value($new_size);
}

if ($this->percent > 0) {
$new_size = $this->calc_percent($width, $height);
return $this->return_value($new_size);
}
}

function show_error_image() {
header("Content-type: image/png");
$err_img = ImageCreate(220, 25);
$bg_color = ImageColorAllocate($err_img, 0, 0, 0);
$fg_color1 = ImageColorAllocate($err_img, 255, 255, 255);
$fg_color2 = ImageColorAllocate($err_img, 255, 0, 0);
ImageString($err_img, 3, 6, 6, "ERROR:", $fg_color2);
ImageString($err_img, 3, 55, 6, $this->errmsg, $fg_color1);
ImagePng($err_img);
ImageDestroy($err_img);
}

function show() {
if ($this->error) {
$this->show_error_image();
return;
}

$size = GetImageSize($this->file);
$new_size = $this->calc_image_size($size[0], $size[1]);
$new_image = ImageCreate($new_size[0], $new_size[1]);

switch ($this->format) {
case "GIF":
$old_image = ImageCreateFromGif($this->file);
break;
case "JPEG":
$old_image = ImageCreateFromJpeg($this->file);
break;
case "PNG":
$old_image = ImageCreateFromPng($this->file);
break;
}

ImageCopyResized($new_image, $old_image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);

switch ($this->format) {
case "GIF":
header("Content-type: image/gif");
ImageGif($new_image);
break;
case "JPEG":
header("Content-type: image/jpeg");
ImageJpeg($new_image);
break;
case "PNG":
header("Content-type: image/png");
ImagePng($new_image);
break;
}

ImageDestroy($new_image);
ImageDestroy($old_image);
return;
}
}
?>

ÀÚ·áÃâó http://www.codelib.co.kr
³×ƼÁð ÀÇ°ß   ÀÌ¿ëÇϽŠÀÚ·áÀÇ Èı⸦ ÀÚÀ¯·Ó°Ô ÀÛ¼ºÇϼ¼¿ä. (»ó¾÷ÀûÀÎ ±¤°í ¹× µµ¹è¼º ±Û µîÀº »çÀüÅ뺸¾øÀÌ »èÁ¦µÉ ¼ö ÀÖ½À´Ï´Ù.)
³»¿ë ¾ÆÀ̵ð ÀÇ°ß³²±â±â
µî·ÏµÈ ÀÇ°ßÀÌ ¾ø½À´Ï´Ù.
1
À̸§
³»¿ë
:³×¸Â¾Æ¿ä: :È­³ª´Â±º¿ä: :Àá¿Í: :¿ì¿ïÇØ: :À̰ǾƳÄ: :¿ÕÇÏÇÏ: ¿Õ¿ôÀ½~ ³î·¥~
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
µµ¹è¹æÁöÅ°
 73541361 º¸ÀÌ´Â µµ¹è¹æÁöÅ°¸¦ ÀÔ·ÂÇϼ¼¿ä.