Takker
Vil prøve at arbejde med det, men det blir nok først og en uges tid, da jeg
skal på ski.
mvh Jan
"Oldorf" skrev i meddelelsen
news:l7vsu293h69vhh2ciq30rij6d71hdn6u40@4ax.com...
> Hvor du skal sætte dette ind er op til dig, men here goes:
>
> Bemærk funktionen er hevet ud af et bibliotek så der kan være andre
> ting der skal tages højde så prøv dig frem !
>
> Lige først de globale variabler der bliver refereret til:
>
> $OS="/";
> Opertivsystemets folder adskiller
> $AlbumRoot="/www/photo/galleri1";
> Sti til der hvor den originale fil ligger UDEN filnavn
> $ThumbnailPreString="";
> Predifineret tekst til at sætte foran thumbnail filnavnet.
> f.eks. $ThumbnailPreString="thumb_";
> $ThumbnailDir="thumb";
> Thumbnail folder, BEMÆRK, dette er IKKE en sti, men navnet på
> en folder, f.eks. kan man lægge sine thumbnails i en seperat
> underfolder i hvert galleri $ThumbnailDir="thumb";
> $TNwidth=80;
> Thumbnail bredde
> $TNhight=80;
> Thumbnail højde
>
>
> function MakeThumbnail($Image, $Album)
> {
> global $OS, $AlbumRoot, $ThumbnailPreString, $ThumbnailDir,
> $TNwidth, $TNhight;
> @ChangeMode($Album);
> $Size = getimagesize($AlbumRoot.$OS.$Album.$OS.$Image);
> if ($Size[2]==2) {
> if ($Size[0] > $Size[1]) {
> $TempTNwidth = $TNwidth;
> $TempTNhight =
> ceil($Size[1]/($Size[0]/$TNwidth));
> $HighOffset = ceil(($TNhight-$TempTNhight)/2);
> }
> else {
> $TempTNhight = $TNhight;
> $TempTNwidth =
> ceil($Size[0]/($Size[1]/$TNhight));
> $WidthOffset =
> ceil(($TNwidth-$TempTNwidth)/2);
> }
> $OldImage =
> @ImageCreateFromJPEG($AlbumRoot.$OS.$Album.$OS.$Image);
> $NewImage = @imagecreatetruecolor($TNwidth, $TNhight);
>
> $colors=imagecolorsforindex($OldImage, imagecolorat($OldImage, 20,
> 20)); // **** new ****
> $BackgroundColor= imagecolorallocate($NewImage, $colors['red'],
> $colors['green'], $colors['blue']); // **** new ****
> imagefill($NewImage, 0, 0, $BackgroundColor); // **** new ****
>
> @imagecopyresampled($NewImage, $OldImage, $WidthOffset,
> $HighOffset, 0, 0, $TempTNwidth, $TempTNhight, $Size[0], $Size[1]);
>
> $Result= @ImageJPEG($NewImage,
> $AlbumRoot.$OS.$Album.$OS.$ThumbnailDir.$OS.$ThumbnailPreString.$Image,
> 100);
>
> imagecolordeallocate($NewImage, $BackgroundColor); // **** new
> ****
> imagedestroy($NewImage); // **** new ****
> imagedestroy($OldImage); // **** new ****
> return $Result;
> }
> else {
> return false;
> }
> }
> ___________________________________________________________
>
> mvh
> Olrik Larsen
> omd[]tra-tanr[]dk
> _____________________
> On Fri, 2 Mar 2007 20:41:26 +0100, "Jan Hansen" <jan.h@rnet.dk> wrote:
>
>>Hej
>>Jeg har følgende upload kode, hvordan laver automatisk jeg thumps, af
>>billider jeg uploader?
>>
>>Mvh jan
>><?php
>>/*=========================================\
>>Author : Mohammed Ahmed(M@@king) \\
>>Version : 1.1 \\
>>Date Created: Oct 11 2004 \\
>>---------------------------- \\
>>Last Update: August 21 2005 \\
>>---------------------------- \\
>>Country : Palestine \\
>>City : Gaza \\
>>E-mail : m@maaking.com \\
>>MSN : m@maaking.com \\
>>AOL-IM : maa2pal \\
>>WWW :
http://www.maaking.com \\
>>Mobile/SMS : 00972-599-622235 \\
>> \\
>>===========================================\
>>---Description -----------------------------------------------------
>>The Super Global Variable $_FILES is used in PHP 4.x.x.
>>$_FILES['filetoupload']['size'] ==> Get the Size of the File in Bytes.
>>$_FILES['filetoupload']['tmp_name'] ==> Returns the Temporary Name of the
>>File.
>>$_FILES['filetoupload']['name'] ==> Returns the Actual Name of the File.
>>$_FILES['filetoupload']['type'] ==> Returns the Type of the File.
>>
>>So if I uploaded the file 'test.doc', the $_FILES['filetoupload']['name']
>>would be 'phptut.doc' and $_FILES['filetoupload']['type'] would be
>>'application/msword'.
>>---------------------------------------------------------------------*/
>>
>>//**********************************************************************//
>>// $_FILES['filetoupload'] is the value of //
>>// file field from the form. <input type="file" name="filetoupload"> //
>>//**********************************************************************//
>>################################################################################
>>##---------------------------1 - Setup
>>################################################################################
>> // this is the upload dir where files will go.
>> //Don't remove the /
>> //Chmod it (777)
>> $upload_dir = "wabbit/my_gallery/images/"; //change to whatever you
>>want.
>> //51200 bytes = 50KB
>> $size_bytes = 10485760; //File Size in bytes (change this value to fit
>>your need)
>> $extlimit = "yes"; //Do you want to limit the extensions of files
>>uploaded (yes/no)
>> $limitedext = array(".jpg",".jpeg"); //Extensions you want files
>> uploaded
>>limited to. also you can use:
>>//array(".gif",".jpg",".jpeg",".png",".txt",".nfo",".doc",".rtf",".htm",".dmg",".zip",".rar",".gz",".exe");
>>################################################################################
>>##---------------------------2 - check for directory and writable
>>################################################################################
>> //check if the directory exists or not.
>> if (!is_dir("$upload_dir")) {
>> die ("Error: The directory <b>($upload_dir)</b> doesn't exist");
>> }
>> //check if the directory is writable.
>> if (!is_writeable("$upload_dir")){
>> die ("Error: The directory <b>($upload_dir)</b> is NOT writable,
>>Please CHMOD (777)");
>> }
>>
>>################################################################################
>>##---------------------------3-1 - code begins here
>>################################################################################
>> if(isset($_POST['uploadform'])){
>> // if you clicked the (Upload File) button. "If you submitted the form"
>>then upload the file.
>> //begin of uploadform.
>>
>> // $filename will hold the value of the file name submetted
>> from
>>the form.
>> $file_tmp = $_FILES['filetoupload']['tmp_name'];
>> $file_name = $_FILES['filetoupload']['name'];
>> //Get the Size of the File
>> $file_size = $_FILES['filetoupload']['size'];
>>
>> //check if no file selected.
>> if (!is_uploaded_file($file_tmp)){
>> echo "Du har ikke valgt et billede. <br>»<a
>>href=\"$_SERVER[PHP_SELF]\">Tilbage</a>";
>> exit(); //exit the script and don't do anything else.
>> }
>>
>>
>> //Make sure that file size is correct
>> if ($file_size > $size_bytes){
>> echo "Billedet er for stort. Max <b>". $size_bytes /
>> 1024/1024
>>."</b> MB. <br>»<a href=\"$_SERVER[PHP_SELF]\">Tilbage</a>";
>> exit();
>> }
>> //check file extension
>> $ext = strrchr($file_name,'.');
>> if (($extlimit == "yes") &&
>>(!in_array(strtolower($ext),$limitedext))) {
>> echo("Billet er af forkert type ");
>> exit();
>> }
>>
>>
>> // Check if file is Already EXISTS.
>> if(file_exists($upload_dir.$file_name)){
>> echo "Der findes allerede et billede der hedder
>><b>$file_name</b> . <br>»<a href=\"$_SERVER[PHP_SELF]\">Tilbage</a>";
>> exit();
>> }
>>
>> //to remove spaces from file name we have to replace it with
>> "_".
>> $file_name = str_replace(' ', '_', $file_name);
>> //Move the File to the Directory of your choice
>> //move_uploaded_file('filename','destination') Moves afile to a
>>new location.
>> if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
>> //tell the user that the file has been uploaded and make
>>him alink.
>> echo "Billede (<a
>>href=\"$upload_dir$file_name\">$file_name</a>) er kommet op. <br>»<a
>>href=\"$_SERVER[PHP_SELF]\">Tilbage</a>";
>> exit();
>> }else{
>> // print error if there was a problem moving file.
>> echo "Billedet kunne ikke sendes <br>»<a
>>href=\"$_SERVER[PHP_SELF]\">Tilbage</a>";
>> exit();
>> }
>>
>>################################################################################
>>##---------------------------3-2 - code to display the form
>>################################################################################
>> //end of if($uploadform).
>> // If the form has not been submitted, display it!
>> }else{
>> //begin of else
>>
>> // get the all extensions from the array
>> for($i=0;$i<count($limitedext);$i++){
>> if (($i<>count($limitedext)-1))$commas=", ";else $commas="";
>> list($key,$value)=each($limitedext);
>> $all_ext .= $value.$commas;
>> }
>>
>> //print the form
>> echo "<br><h3>Find dit billede der skal sendes</h3>"
>> ."- Billed typer $all_ext</b> <br>"
>> ."- Max Fil størelse = ". $size_bytes / 1024/1024 . "
>> MB"
>> ."<form method=\"post\" enctype=\"multipart/form-data\"
>>action=\"$PHP_SELF\">"
>> ."<input type=\"file\" name=\"filetoupload\"><br>"
>> ."<input type=\"hidden\" name=\"MAX_FILE_SIZE\"
>>value=\"$size_bytes\"><br>"
>> ."<input type=\"Submit\" name=\"uploadform\" value=\"Upload
>>billedet!\">"
>> ."</form>";
>> }//end of else
>>
>>
>>echo"
>></body>
>></html>";
>>
>>?>