resize image php
resize image php
je nejaky script ktory resizne pomocu php obrazok napr. z 1000x1200px na 100x100px? diki
-
masterdead
SysAdmin
- Príspevky: 1809
- Registrovaný: 03 aug 2005, 23:32
- Bydlisko: Bratislava
- Kontaktovať používateľa:
Kód: Vybrať všetko
http://www.ipowerplant.com/download/image_resize.zip
Not Found
The requested URL /download/image_resize.zip was not found on this server.
Apache/2.0.55 (Unix) PHP/4.4.2 mod_ssl/2.0.55 OpenSSL/0.9.7e-p1 Server at www.ipowerplant.com Port 80-
t0m4s3
Admin
- Príspevky: 18096
- Registrovaný: 14 jún 2004, 18:35
- Bydlisko: Martin SR, Brno CZ
- Kontaktovať používateľa:
tak miesto smajliku si sem tie tri riadky mohol dat a bol by pokojlammer napísal:
uz len kvoli tomu simple som to chcel vidiet kedze je to mozne napisat na tri riadkyKód: Vybrať všetko
http://www.ipowerplant.com/download/image_resize.zip Not Found The requested URL /download/image_resize.zip was not found on this server. Apache/2.0.55 (Unix) PHP/4.4.2 mod_ssl/2.0.55 OpenSSL/0.9.7e-p1 Server at www.ipowerplant.com Port 80
-
masterdead
SysAdmin
- Príspevky: 1809
- Registrovaný: 03 aug 2005, 23:32
- Bydlisko: Bratislava
- Kontaktovať používateľa:
http://www.megaupload.com/?d=CIDU5XELetel napísal:to: masterdead
neuploadol by si to este raz ,pls ??? alebo mi to posli na mail ...
trocha upravene som to supol na server ...
PS : neslo mi to ani ked to bolo original ....
tu je zdrojak:
neviete kde moze byt chyba ???
Kód: Vybrať všetko
Warning: imagejpeg(): Unable to open 'okkk.jpg' for writing in /new_usr/virtualhosts/www.server.sk/forum/temp/home.php on line 20
Warning: copy(okkk.jpg): failed to open stream: No such file or directory in /new_usr/virtualhosts/www.server.sk/forum/temp/home.php on line 21
Warning: unlink(okkk.jpg): No such file or directory in /new_usr/virtualhosts/www.server.sk/forum/temp/home.php on line 22
Warning: filesize(): Stat failed for resized/okkk.jpg (errno=2 - No such file or directory) in /new_usr/virtualhosts/www.server.sk/forum/temp/home.php on line 25tu je zdrojak:
Kód: Vybrať všetko
<?header("Pragma: no-cache");
require "conf.php";
$cur_file = "betiss.jpg";
$copy_file = "okkk.jpg";
$widthto = 100;
$heightto = 100;
$quality = 100;
$ssize=GetImageSize($cur_dir."/".$cur_file); //get size
$end = Explode(".", $cur_file); //oddìlení pøípony....nyní je pøípona pøístupná v promìnné $end[1]
$fp = imagecreatefromjpeg ($cur_dir."/".$cur_file);
$fx = imagecreate ($widthto,$heightto-1);
imagecopyresized ($fx,$fp,0,0,0,0,$widthto,$heightto,$ssize[0],$ssize[1]);
//if ($interlace == "on"):
ImageInterlace($fx , 1);
//endif;
imageJPEG ($fx, $copy_file, $quality);
Copy($copy_file, $copy_dir."/".$copy_file);
unlink($copy_file);
ImageDestroy($fp);
ImageDestroy($fx);
$kilo = Round(FileSize($copy_dir."/".$copy_file)/1024, 2);
echo "<div align=\"center\"><b>".$cur_file." => ".$copy_file."</b><br><b>".$widthto." X ".$heightto." px ; ".$kilo." Kb</b><br></div>";
echo "<div align=\"center\"><img src=\"resized/".$copy_file."\"><br><br></div>";?>-
hojko
Site Admin
- Príspevky: 38514
- Registrovaný: 24 apr 2004, 18:29
- Bydlisko: Európa
- Kontaktovať používateľa:
http://www.google.com/search?hl=en&q=php+image+resize
Ale ak sa nemylim, tak je nutne, aby server mal Imagick.
Ale ak sa nemylim, tak je nutne, aby server mal Imagick.
nemozes obrazok zmensit ako chces, musis zachovat pomer stran, inac sa obrazok deformujeetel napísal:jo este .... teoreticky by to mohlo byt tak ze susbor uploadnem na server tam sa oreze a ulozi sa do toho isteho suboru ..... ale nejde mi to iba na serveri .... shit ...
Kód: Vybrať všetko
$imagefile_name = $_FILES['imagefile']['name'];
$bigsize=120;
$imgfile = $_FILES['imagefile']['tmp_name'];
list($width, $height) = getimagesize($imgfile);
$imgratio=$width/$height;
if (($width>$bigsize) or ($height>$bigsize))
{
if ($imgratio>1)
{
$bigwidth = $bigsize;
$bigheight = $bigsize/$imgratio;
}
elseif ($imgratio==1)
{
$bigheight = $bigsize;
$bigwidth = $bigsize;
}
else
{
$bigheight = $bigsize;
$bigwidth = $bigsize*$imgratio;
}
$bigthumb = ImageCreateTrueColor($bigwidth,$bigheight);
$bigsource = imagecreatefromjpeg($imgfile);
imagecopyresized($bigthumb, $bigsource, 0, 0, 0, 0, $bigwidth, $bigheight, $width, $height);
imagejpeg($bigthumb,"image/$imagefile_name",100);
}
else
{
copy ($_FILES['imagefile']['tmp_name'], "image/".$_FILES['imagefile']['name']) or die ("Could not copy");
}-
caesar1987
Addict
- Príspevky: 3001
- Registrovaný: 02 okt 2005, 0:57
- Bydlisko: Nové Zámky
- Kontaktovať používateľa:
Tiez pridam
:
Kód: Vybrať všetko
<?
if(isset($_POST[send])) {
$file = $_FILES["subor"]["tmp_name"];
$file_name = $_FILES["subor"]["name"];
$pic = @imagecreatefromjpeg($subor) or die ("Neda sa najst obrazok!");
if ($pic) { // ak najde povodny obrazok
$width=imagesx($pic);
$height=imagesy($pic);
if ($width>$height){
$twidth = 640;
$theight = $twidth * $height / $width;
} else {
$theight = 640;
$twidth = $theight * $width / $height;
}
$thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Nemožno vytvorit maly obrazok!");
imagecopyresized($thumb, $pic, 0, 0, 0, 0,
$twidth, $theight, $width, $height);
ImageJPEG($thumb,"/***/**/***/*/*****/***/***/_photos/".$file_name."",85);
ImageDestroy($pic);
ImageDestroy($thumb);
}
}
?>ako to spravim aby mi kvalita obrazku bola taka ista ... straca mi to farbu, sedne to ... ???
kod:
kod:
Kód: Vybrať všetko
$src_function = "ImageCreateFromjpeg";
$dst_function = "Imagejpeg";
$ext = "jpeg";
$unique = UniqID(""); //vytvoøíme unikátní ID obrázku
//dl("php_gd.dll"); //naèteme knihovnu pro práci s obrázky
@mkdir("../cars/".$unique, 0755);
$max_width = 250;
$max_height = 150;
list($width_orig, $height_orig) = getimagesize("../temp/".$destination_file);
// zistime mieri obr
if ($max_width && ($width_orig < $height_orig)) {
$max_width = ($max_height / $height_orig) * $width_orig;
} else {
$max_height = ($max_width / $width_orig) * $height_orig;
}
//zapiseme obr do súbor
$image_p = imagecreate($max_width, $max_height);
$image = ImageCreateFromjpeg("../temp/".$destination_file) or die("er1");
ImageCopyResized($image_p, $image, 0, 0, 0, 0,$max_width, $max_height, $width_orig, $height_orig) or die("er2");
imagejpeg($image_p, "../cars/".$unique."/".$unique.".".$ext) or die("er3");
$link = $unique."/".$unique.".".$ext;
jou ... nasiel som co som hladal ... jednoduchy skript ktory staci trochu upravit ...
- Prílohy
-
- php_image_snapshot.zip
- zmena velkosti foto
- (5.44 KiB) 101 stiahnutí
mylis sa, druha varianta je GD kniznica, ktora je v sucasnosti na vacsine hostingov standartne a ktorej prikazy sa tu standatne pouzivaju.hojko napísal:http://www.google.com/search?hl=en&q=php+image+resize
Ale ak sa nemylim, tak je nutne, aby server mal Imagick.