Autor Zpráva
pepas
Profil *
Dobry den pouzivam tuto tridu na generovani 3 ruznych velikosti jednoho obrazku
class thumbnail
	{

/**
* zdrojovy soubor
* @access private
* @var blob
*/
		var $sourceFile; // z tohoto se dela nahled
		var $originalFilename; // pro ziskani dalsic informaci
		var $destinationDirectory; // slozka pro data
		var $destinationDirectoryFilename; // vysledny soubor

		var $createImageFunction = '';
		var $outputImageFunction = '';

		function generate($sourceFile = "", $originalFilename = "", $destinationDirectory = "", $destinationDirectoryFilename = "", $width = -1, $height = -1)
		{
      if (!empty($sourceFile))
        $this->sourceFile = $sourceFile;

      if (!empty($originalFilename))
        $this->originalFilename = $originalFilename;

      if (!empty($destinationDirectory))
        $this->destinationDirectory = $destinationDirectory;

      if (!empty($destinationDirectoryFilename))
        $this->destinationDirectoryFilename = $destinationDirectoryFilename;

      if (!empty($width))
        $this->width = $width;

      if (!empty($height))
        $this->height = $height;

      list(, $this->extension) = explode('.', $this->originalFilename);

			switch ($this->extension)
			{
				case 'gif' :
					$createImageFunction = 'imagecreatefromgif';
					$outputImageFunction = 'imagegif';
				  break;

				case 'png' :
					$createImageFunction = 'imagecreatefrompng';
					$outputImageFunction = 'imagepng';
				  break;

				case 'jpg': case 'jpeg':
					$createImageFunction = 'imagecreatefromjpeg';
					$outputImageFunction = 'imagejpeg';
				  break;

				default :
					exit("Prominte, tento format '{$this->extension}' neni podporovan. Podporovan jen .jpg, .png, .gif malymi pismeny. Musite prepsat nazvy souboru");
				  break;
			}

			$this->img  = $createImageFunction($this->sourceFile);

			// vyska/sirka
			list($this->org_width, $this->org_height) = getimagesize($this->sourceFile);

			if ($this->height == -1)
			{
				$this->height = round($this->org_height * $this->width / $this->org_width);
			}

			if ($this->width == -1)
			{
				$this->width = round($this->org_width * $this->height / $this->org_height);
			}

			$this->xoffset = 0;
			$this->yoffset = 0;

			$this->img_new = imagecreatetruecolor($this->width, $this->height) or die ("FATAL ERROR GD");

			if ($this->img_new)
			{
				// resample obrazku
				imagecopyresampled($this->img_new, $this->img, 0, 0, $this->xoffset, $this->yoffset, $this->width, $this->height, $this->org_width, $this->org_height);

				list($this->newFilename) = explode('.', $this->destinationDirectoryFilename);

				// cesta k vyslednemu souboru
				$this->fullDestination = ($this->destinationDirectory.'/'.$this->newFilename.'.'.$this->extensi on);

				$outputImageFunction($this->img_new, $this->fullDestination);
			}
			else
			{
				$this->failed = true;
			}

			if ($this->failed == false)
			{
				return $this->fullDestination;
			}
		}
	}


trida by mela byt funkcni. Bohuzel ale nedela co ma a to je upload obrazku na server.
Php mi hlasi chybu
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'thumb/uploads/14_lrg.jpg' for writing: No such file or directory in P:\EasyEclipse\workspace\mimibazar\inc\thumb\thumbnail.class.php on line 103

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'thumb/uploads/14_med.jpg' for writing: No such file or directory in P:\EasyEclipse\workspace\mimibazar\inc\thumb\thumbnail.class.php on line 103

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'thumb/uploads/14_sml.jpg' for writing: No such file or directory in P:\EasyEclipse\workspace\mimibazar\inc\thumb\thumbnail.class.php on line 103


Paramtetry predavam spravne, nevite kde by mohla byt chyba?
nightfish
Profil
Paramtetry predavam spravne, nevite kde by mohla byt chyba?
víme
soubor 'thumb/uploads/14_lrg.jpg' v adresáři P:\EasyEclipse\workspace\mimibazar\inc\thumb\ neexistuje
pepas
Profil *
no jasne ale nechapu proc jej tam ta trida nenahraje? nebo to mam delat ja rucne?
nightfish
Profil
teda spíš jsem měl napsat, že neexistují adresáře thumb a/nebo thumb/uploads na uvedené cestě... ty zřejmě bude potřeba vytvořit ručně
pepas
Profil *
Tyto adresare existuji, ale trida do nich nic nevyexportuje, cili zadne obrazky neobsahuje.
nightfish
Profil
ještě jednou
existuje adresář
P:\EasyEclipse\workspace\mimibazar\inc\thumb\thumb
a
P:\EasyEclipse\workspace\mimibazar\inc\thumb\thumb\uploads

(protože PHP tvrdí, že ne)
ještě mě napadá - není náhodou P nějaká síťová jednotka? resp. má na ni uživatel, pod kterým běží apache, přístup?
pepas
Profil *
super byla to chyba adresarove struktury v nastaveni stacilo dopsat inc a hotovo, diky

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0