Janhouse Posted April 30, 2006 Report Share Posted April 30, 2006 tatad man te nelies skriptins, kurs samazina bildi: <?php // File and new size $filename = '1.jpg'; // Content type header('Content-type: image/jpeg'); // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = 100; $newheight = 80; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?> Ka izveidoto bildi saglabat kada mapite uz servera? Link to comment Share on other sites More sharing options...
bubu Posted April 30, 2006 Report Share Posted April 30, 2006 rtfm: http://php.net/imagejpeg bool imagejpeg ( resource image [, string filename [, int quality]] ) imagejpeg() creates the JPEG file in filename from the image image. Link to comment Share on other sites More sharing options...
Janhouse Posted April 30, 2006 Author Report Share Posted April 30, 2006 bet vins kautkada defaultajaa mapite to bildi saglabaa. man vajag citaa. tas imagejpeg() to bilditi tikai uztaisa un parada caur browseri, bet ka vinu saglabat kada izveleta mape? Link to comment Share on other sites More sharing options...
bubu Posted April 30, 2006 Report Share Posted April 30, 2006 Kuru no boldā izceltajiem vārdiem tu nesaproti? Link to comment Share on other sites More sharing options...
Janhouse Posted April 30, 2006 Author Report Share Posted April 30, 2006 Saparu, ka ar šo galā netikšu. Varbūt kāds var parādīt, kā atvērt failu no cietā, samazināt un saglabāt uz servera? Link to comment Share on other sites More sharing options...
bubu Posted April 30, 2006 Report Share Posted April 30, 2006 jopcig.. imagejpeg($thumb, 'celjsh/uz/failu/fails.jpeg'); Link to comment Share on other sites More sharing options...
Janhouse Posted April 30, 2006 Author Report Share Posted April 30, 2006 Thanx. Saglabaja gan mapiitee. :D Tagad tik jaizdoma parejais. :D Nakamais jautajums. Tatad vins tos failus man atvers tikai no servera cietaa. ka uzlitk, lai vins uploado kautkadu bildi no cita datora? Link to comment Share on other sites More sharing options...
john.brown Posted April 30, 2006 Report Share Posted April 30, 2006 Klau, tas jau ir vājprāts! Mācies angļu valodu un draudzējies ar manuāli, vai arī met pie malas programmēšanu! Bez tam search lietot mācies, forumā failu uploads ir aprunāts 256 reizes! Link to comment Share on other sites More sharing options...
Janhouse Posted April 30, 2006 Author Report Share Posted April 30, 2006 pirmkart es atradu atbildi caur search :) otrkart laikam biju akls, kad lasiju manuali. kludu pamaniju pec 1 h. :) Link to comment Share on other sites More sharing options...
Janhouse Posted April 30, 2006 Author Report Share Posted April 30, 2006 Laikam tomēr kļūdījos! Neesmu visu atrisinājis. Tikutik tālu ar upload, kurš strādāperfekti: $uploaddir = 'pictures/users/avatars/'; $veidz=$_FILES['userfile']['type']; //$fails=$_FILES['userfile']['name']; if ($veidz=="image/jpeg" or $veidz=="image/bmp" or $veidz=="image/png"){ $damn="$idIN.jpg"; $_FILES['userfile']['name']=$damn; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "Fails tika veiksmīgi ielādēts uz servera.\n"; } else { print"Failu neizdevās ielādēt uz servera!"; } } else { print"Faila formāts neatbilsts! Var ielādēt tikai .jpg, .bmp un .png formāta bildes."; //echo 'Here is some more debugging info:'; //print_r($_FILES); } Bet nesaprotu, kā tajā kodā piemontēt to samazināšanas skriptiņu... <?php // Content type header('Content-type: image/jpeg'); // File and new size $id = $HTTP_GET_VARS['id']; $filename = "$id.jpg"; $adreseJOU="pictures/users/avatars/$id.jpg"; // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = 100; $newheight = 80; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output //imagejpeg($thumb, $adreseJOU); imagejpeg($thumb); ?> [/b]Tas header('Content-type: image/jpeg'); visu prieku bojā, bet bez tā tak nekādīgi. :) [/b] Link to comment Share on other sites More sharing options...
john.brown Posted April 30, 2006 Report Share Posted April 30, 2006 un priekš kam tev brauserī jādod ārā tas imagejpg()? Ja gribi parādīt, kāda smuka, maza bildīte sanāca, tad liec vienkārši: echo '<img src="'.$adreseJOU.'">'; Un nekāds hederis nav vajadzīgs Link to comment Share on other sites More sharing options...
Janhouse Posted May 1, 2006 Author Report Share Posted May 1, 2006 bet kur tad vins to failu saglabas? nekur tak. Man vajag ne tikai samazinat, bet to samazinato failu saglabat... Link to comment Share on other sites More sharing options...
john.brown Posted May 1, 2006 Report Share Posted May 1, 2006 Tu bremze esi, vai? // Output imagejpeg($thumb, $adreseJOU); Ja tu uzrādi faila nosaukumu kā otro parametru, viņš tur arī saglabās. Ja nē, tad viņš drukā to bildi standarta outputā, t.b. brauserī! Link to comment Share on other sites More sharing options...
Recommended Posts