WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   [php] thumbnail (http://www.wcm.at/forum/showthread.php?t=121430)

mqs 09.01.2004 09:36

[php] thumbnail
 
hi!
hab ne frage zu folgendem code:

PHP-Code:

$src_img LoadJPG ($uploaddir);
$new_w 160;
$new_h 140;
$dst_img ImageCreateTrueColor($new_w,$new_h);
imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img));
imagejpeg($dst_img"archiv/thumbnail/$imagefile"); 

ich will aus dem vorhandenen bild ein thumbnail machen... aber irgendwie bekomm ich da den folgenden fehler

Code:

Fatal error: Call to undefined function: loadjpg() in d:\nusphere\apache\htdocs\il_galerie\function.php on line 29
hab mir gedacht, dass mir da evt. ne libary abgeht ... weiss jemand wo der hund begraben liegt?

snowman 09.01.2004 10:11

er sagt dir den fehler ja eh: die funktion in der ersten zeile ist offenbar nicht definiert.

gruss,
snowman

mqs 09.01.2004 10:16

hmm naja tja habs hinbekommen
PHP-Code:

    header("Content-type: image/jpeg"); 
    
Header("Content-type: image/png"); 
    
$image_name=$dateiname;
    
$new_width=170;  //Image width Change if needed 
    
$new_height=150;  //Image height Change if needed 
    
$source_path="archiv/orginal/";   //Source File path 
    
$destination_path="archiv/thumbnail/";     //Destination file path 

    
$destimg=ImageCreate($new_width,$new_height) or die("Problem In Creating image"); 
    
$srcimg=ImageCreateFromJPEG($source_path.$image_name) or die("Problem In opening Source Image"); 
    
ImageCopyResized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die("Problem In resizing"); 
    
ImageJPEG($destimg,$destination_path.$image_name) or die("Problem In saving"); 

aber an der qualität des bildes kann man nichts ändern oder? ist n wenig gekräuselt

mqs 09.01.2004 11:39

ok dieses problem hat sich auch schon geklärt...
habs n wenig anders machen müssen.
zu info für andere:

PHP-Code:

            $src_img imagecreatefromjpeg ($uploaddir);
            
$imageinfo getimagesize($uploaddir);
            if(
$imageinfo[0]==$imageinfo[1])
            {
                
$new_w $x;
                
$new_h $x;
            }
            elseif(
$imageinfo[0]>$imageinfo[1])
            {
                
$new_w $x;
                
$ratio $imageinfo[0]/$x;
                
$new_h $imageinfo[1]/$ratio;
            }
            elseif(
$imageinfo[0]<$imageinfo[1])
            {
                
$new_h $x;
                
$ratio $imageinfo[1]/$x;
                
$new_w $imageinfo[0]/$ratio;
            }
    
         
$dst_img imagecreatetruecolor($new_w,$new_h);
         
imagecopyresampled($dst_img$src_img0000$new_w,$new_himagesx($src_img), imagesy($src_img));
         
imagejpeg $dst_img $dir "archiv/thumbnail/".$dateiname);
         
imagedestroy($src_img);
         
imagedestroy($dst_img); 



Alle Zeitangaben in WEZ +2. Es ist jetzt 17:43 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag