IT NEWS PC REVUE PC FORUM FreeBSDInternet time: @445
Obsah fóra
Pravidlá  •  Kontakt  •  Prihlásenie  •  Registrácia

Ekonomický softvér KROS

Programy na vedenie komplexnej agendy JÚ a PÚ. Vyskúšajte demo zadarmo! www.kros.sk

Účtovníctvo, Faktúry, Sklady

jednoducho ovládateľné programy od MRP za 20 rokov cez 100000 inštalácií www.mrp.sk

Top novinka v O2 e-shope

Objednajte si dlhoočakávaný Samsung Galaxy S III. V e-shope za 589,63 € pausal.o2.sk

Získajte bonus 50 €

Prejdite na ktorýkoľvek program s platbou na faktúru. Len cez e-shop. www.o2.sk

Neuveriteľne lacná .sk doména

Rýchla registrácia domén za výborné ceny. www.exohosting.sk

Orezevanie obrazkov .php //vyriesene

Zaslať odpoveď
AutorSpráva
KViki
Užívateľ
Užívateľ

Založený: 21.10.2008
Príspevky: 197
Bydlisko: Nitra

PríspevokZaslal: St 23.11.11 14:58Odpovedať s citátomNávrat hore

Na nahladi obrazkov na webe pouzivam tento kod, ktory funguje dobre.
Ale je tam jeden problem ze nespracuje subor ktory ma v nazve medzeru
vie mi s tym niekto pomoct ?

kód:
<?
header ("Content-type: image/jpeg");
$file_name = $_GET['f'];
$crop_height=$_GET['h'];
$crop_width=$_GET['w'];
$folder=$_GET['folder'];

$file_type= explode('.', $file_name);
$file_type = $file_type[count($file_type) -1];
$file_type=strtolower($file_type);

$file_name = 'domain/uploads/'.$folder.'/'.$file_name;

$original_image_size = getimagesize($file_name);
$original_width = $original_image_size[0];
$original_height = $original_image_size[1];

if($file_type=='jpg' OR $file_type=='jpeg' OR $file_type=='JPG' OR $file_type=='JPEG')
{
$original_image_gd = imagecreatefromjpeg($file_name);
}

if($file_type=='gif')
{ $original_image_gd = imagecreatefromgif($file_name);
}   

if($file_type=='png')
{
$original_image_gd = imagecreatefrompng($file_name);
}

$cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height);
$wm = $original_width /$crop_width;
$hm = $original_height /$crop_height;
$h_height = $crop_height/2;
$w_height = $crop_width/2;

if($original_width > $original_height )
{
$adjusted_width =$original_width / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;

imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height );
}
elseif(($original_width < $original_height ) || ($original_width == $original_height ))
{
$adjusted_height = $original_height / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;

imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height );
}
else {

imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height );
}
imagejpeg($cropped_image_gd);

?>


///////////////////////
Vyriesil som to tym ze som dal hladat medzeru v nazve konkretneho suboru a zamenil som ju za "%20"

na riadok 11 som pridal

kód:
$file_name = str_replace(" ", "%20", $file_name);
Zobraziť informácie o autoroviOdoslať súkromnú správuOdoslať e-mailICQ
Zobraziť príspevky z predchádzajúcich:    
Zaslať odpoveď
Nemôžete pridávať nové témy do tohto fóra.
Nemôžete odpovedať na témy v tomto fóre.
Nemôžete upravovať svoje príspevky v tomto fóre.
Nemôžete mazať svoje príspevky v tomto fóre.
Nemôžete hlasovať v tomto fóre.

Powered by phpBB 2.x.x © 2005 - 2012 PCforum, webhosting by WebSupport, edited by JanoF

SEO - optimalizácia pre vyhľadávače

Freebsd