azizny
08-15-2005, 09:35 PM
I do not have access to neither GD or ImageMagick.. I am using this fuction:
function make_thumb($filename,$max_width,$max_height,$image_dir_in,$image_dir_out){
$comp_name = $image_dir_in ."/$filename";
$thumb_dir = $image_dir_out;
if( !file_exists( $thumb_dir ."/$filename" )) {
if ( strstr ( $filename, '.gif' ) ) {
$im = imagecreatefromgif( $path . $comp_name);
}
elseif ( preg_match( '/(.jpg|.jpeg)/i', $comp_name ))
{
$im = imagecreatefromjpeg( $path . $comp_name);
}
elseif ( preg_match( '/.png/i', $comp_name ))
{
$im = imagecreatefrompng( $path . $comp_name);
}
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0,0,0);
$y = 50 * imagesy($im) / 100;
$widths = imagesx($im);
$heights = imagesy($im);
if ( $widths > $max_width ) {
$img_width = $max_width;
$img_height = ceil( ( $heights * ( ( $max_width * 100 ) / $widths ) ) / 100 );
$heights = $img_height;
$widths = $img_width;
} else {
$img_height = $heights;
}
if ( $heights > $max_height ) {
$img_height = $max_height;
$img_width = ceil( ( $widths * ( ( $max_height * 100 ) / $heights ) ) / 100 );
} else {
$img_width = $widths;
}
$newwidth = $img_width;
$newheight = $img_height;
$sourcedata = getimagesize ( $path . $comp_name );
$image = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($image,$im,0,0,0,0,$newwidth,$newheight,$sourcedata[0],$sourcedata[1]);
$a = imagejpeg($image, $thumb_dir ."/$filename");
}
}
Some black text shows white instead and the background goes all black..
Any hints or other functions that might work will be appreciated,
Thanks,
Aziz
function make_thumb($filename,$max_width,$max_height,$image_dir_in,$image_dir_out){
$comp_name = $image_dir_in ."/$filename";
$thumb_dir = $image_dir_out;
if( !file_exists( $thumb_dir ."/$filename" )) {
if ( strstr ( $filename, '.gif' ) ) {
$im = imagecreatefromgif( $path . $comp_name);
}
elseif ( preg_match( '/(.jpg|.jpeg)/i', $comp_name ))
{
$im = imagecreatefromjpeg( $path . $comp_name);
}
elseif ( preg_match( '/.png/i', $comp_name ))
{
$im = imagecreatefrompng( $path . $comp_name);
}
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0,0,0);
$y = 50 * imagesy($im) / 100;
$widths = imagesx($im);
$heights = imagesy($im);
if ( $widths > $max_width ) {
$img_width = $max_width;
$img_height = ceil( ( $heights * ( ( $max_width * 100 ) / $widths ) ) / 100 );
$heights = $img_height;
$widths = $img_width;
} else {
$img_height = $heights;
}
if ( $heights > $max_height ) {
$img_height = $max_height;
$img_width = ceil( ( $widths * ( ( $max_height * 100 ) / $heights ) ) / 100 );
} else {
$img_width = $widths;
}
$newwidth = $img_width;
$newheight = $img_height;
$sourcedata = getimagesize ( $path . $comp_name );
$image = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($image,$im,0,0,0,0,$newwidth,$newheight,$sourcedata[0],$sourcedata[1]);
$a = imagejpeg($image, $thumb_dir ."/$filename");
}
}
Some black text shows white instead and the background goes all black..
Any hints or other functions that might work will be appreciated,
Thanks,
Aziz
