Forum Moderators: coopster
<snip>
I can't do that thing. I don't want to resize the whole image. I just want to resize canvas.
I think it could be like this;
$im = imagecreatefromjpeg ( 'test.jpg' );
$width = imagesx($im);
$height = imagesy($im);
$canvas = imagecreatetruecolor($width, $height + 15); Maybe i can join them. But i can't find the functions.
Anyone can help me by that way? Or any other ways to do this?
[edited by: Seregwethrin at 12:32 pm (utc) on May 24, 2008]
[edited by: dreamcatcher at 1:40 pm (utc) on May 24, 2008]
[edit reason] No urls please! [/edit]
function drow_thumb ()
{
if ( $this->img['thumbnail'] == '1' )
{
if ( $this->img['realext'] == 'jpg' )
$im = imagecreatefromjpeg ( $this->img['thumbpath'] );
elseif ( $this->img['realext'] == 'gif' )
$im = imagecreatefromgif ( $this->img['thumbpath'] );
elseif ( $this->img['realext'] == 'png' )
$im = imagecreatefrompng ( $this->img['thumbpath'] );$thumbW = imagesx ( $im );
$thumbH = imagesy ( $im );
$canvas = imagecreatetruecolor($thumbW, $thumbH + 15);
imagecopy ( $canvas , $im , 0 , 0 , 0 , 0 , $thumbW, $thumbH );
imagedestroy ( $im );
$thumbH += 15;
$white = imagecolorallocate($canvas, 255, 255, 255);
$black = imagecolorallocate($canvas, 0, 0, 0);
imagefilledrectangle ( $canvas , 0 , $thumbH - 15 , $thumbW , $thumbH , $black );
imagerectangle ( $canvas , 0 , 0 , $thumbW - 1 , $thumbH - 1 , $black );
if ( $this->img['size'] < 1024 )
$imghsize = $this->img['size'] . 'b';
elseif ( $this->img['size'] < 1024*1024 )
$imghsize = intval ( $this->img['size'] / 1024 ) . 'kb';
elseif ( $this->img['size'] >= 1024*1024 )
$imghsize = intval ( $this->img['size'] / 1024 / 1024 ) . 'mb';
$text = $this->img['width'] . 'x' . $this->img['height'] . ' ' . $imghsize;
$textwidth = ceil ( '6' * strlen ( $text ) );
$lefttextspace = intval ( ( $thumbW - $textwidth ) / 2 );
if ( $textwidth >= $thumbW )
{
$text = $imghsize;
$textwidth = ceil ( '6' * strlen ( $text ) );
$lefttextspace = intval ( ( $thumbW - $textwidth ) / 2 );
}
imagestring ( $canvas , 2 , $lefttextspace , $thumbH - 14, $text , $white );
if ( $this->img['realext'] == 'jpg' )
imagejpeg ( $canvas , $this->img['thumbpath'] );
elseif ( $this->img['realext'] == 'gif' )
imagegif ( $canvas , $this->img['thumbpath'] );
else
imagepng ( $canvas , $this->img['thumbpath'] );
imagedestroy ( $canvas );
}
$this->insert_into_sql();
}
[edited by: Seregwethrin at 1:31 pm (utc) on May 24, 2008]