[ Irfank @ 13.05.2007. 14:37 ] @
Da li mozete da pogledate ovu skriptu izbacuje mi gresku:

Fatal error: Call to undefined function imagecreatefromjpeg() in D:\Programi\Apache HTTP Server 2.0\Apache2\htdocs\Rezize.php on line 21

Code:
<?php
$idir = "slic/";   // Path To Images Directory
$tdir = "slic/thumbs/";   // Path To Thumbnails Directory
$twidth = "125";   // Maximum Width For Thumbnail Images
$theight = "100";   // Maximum Height For Thumbnail Images

if (!isset($_GET['subpage'])) {   // Image Upload Form Below   ?>
  <form method="post" action="Rezize.php?subpage=upload" enctype="multipart/form-data">
   File:<br />
  <input type="file" name="imagefile" class="form">
  <br /><br />
  <input name="submit" type="submit" value="Sumbit" class="form">  <input type="reset" value="Clear" class="form">
  </form>
<? } else  if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') {   // Uploading/Resizing Script
  $url = $_FILES['imagefile']['name'];   // Set $url To Equal The Filename For Later Use
  if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") {
    $file_ext = strrchr($_FILES['imagefile']['name'], '.');   // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php
    $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']);   // Move Image From Temporary Location To Permanent Location
    if ($copy) {   // If The Script Was Able To Copy The Image To It's Permanent Location
      print 'Image uploaded successfully.<br />';   // Was Able To Successfully Upload Image
      $simg = imagecreatefromjpeg("$idir" . $url);   // Make A New Temporary Image To Create The Thumbanil From
      $currwidth = imagesx($simg);   // Current Image Width
      $currheight = imagesy($simg);   // Current Image Height
      if ($currheight > $currwidth) {   // If Height Is Greater Than Width
         $zoom = $twidth / $currheight;   // Length Ratio For Width
         $newheight = $theight;   // Height Is Equal To Max Height
         $newwidth = $currwidth * $zoom;   // Creates The New Width
      } else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
        $zoom = $twidth / $currwidth;   // Length Ratio For Height
        $newwidth = $twidth;   // Width Is Equal To Max Width
        $newheight = $currheight * $zoom;   // Creates The New Height
      }
      $dimg = imagecreate($newwidth, $newheight);   // Make New Image For Thumbnail
      imagetruecolortopalette($simg, false, 256);   // Create New Color Pallete
      $palsize = ImageColorsTotal($simg);
      for ($i = 0; $i < $palsize; $i++) {   // Counting Colors In The Image
       $colors = ImageColorsForIndex($simg, $i);   // Number Of Colors Used
       ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);   // Tell The Server What Colors This Image Will Use
      }
      imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);   // Copy Resized Image To The New Image (So We Can Save It)
      imagejpeg($dimg, "$tdir" . $url);   // Saving The Image
      imagedestroy($simg);   // Destroying The Temporary Image
      imagedestroy($dimg);   // Destroying The Other Temporary Image
      print 'Image thumbnail created successfully.';   // Resize successful
    } else {
      print '<font color="#FF0000">ERROR: Unable to upload image.</font>';   // Error Message If Upload Failed
    }
  } else {
    print '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is ';   // Error Message If Filetype Is Wrong
    print $file_ext;   // Show The Invalid File's Extention
    print '.</font>';
  }
} ?>
[ dakipro @ 13.05.2007. 15:53 ] @
Bez gledanja koda, najverovatnije nemas ukljucenu GD biblioteku u php-u. pogledaj sa phpinfo(); da li ti je ukljucena gd library jer imagecreatefromjpeg() postoji u toj biblioteci.
[ flylord @ 13.05.2007. 15:53 ] @
Treba ti 2min da nadjes na google sta je problem. A verujem da ima i na esu vec ovakvo pitanje.

Fali ti podrska za jpeg.
[ Irfank @ 17.05.2007. 17:16 ] @
Kako mogu da uploadujem samo ovu malu sliku bez ove velike originalne?
[ dakipro @ 17.05.2007. 18:12 ] @
Toliko ti je komentovan kod, a ti pitas ovako nesto. Samo je obrisi nakon pravljenja thumbnail-a. Ili je smanji pre uploada, posto si pitao kako da uploadujes samo umanjenu sliku.
Sumnjam da se nisi sam setio ovoga.
[ Irfank @ 17.05.2007. 22:03 ] @
Znas kako, napravio sam kod koji ce obrisati tu sliku ali je bezveze cekati da se slika
uploaduje kad cu je obrisati, a sto se tice modifikovanja koda pokusavao sam ali
uvek mi izbacuje neki error.
Hajde pomozi
[ dakipro @ 17.05.2007. 22:22 ] @
pazi, da bi iz php-a mogao da pristupis slici, moras da je uploadujes. Znaci, ne mozes sliku 'u letu' ka serveru da editujes, resizujes itd. Cak php4 (bez hakovanja) ne moze da pristupi fajlu sve dok on nije kompletno uploadovan. Znaci ili cekas da se uploaduje, ili nekim programom na sopstvenom racunaru je smanjis, pa onda umanjenu sliku posaljes serveru (u ovom slucaju, ti, logicno, ne treba ovaj tvoj kod za resize, a i ne cekas ).