|
משתף אותך בקוד שלי מהאתר שלי loading.co.il בהקטנת תמונות + כתיבה וכו'
מכיוון שפרש זה פורום שלוט החלטתי לפרסם את הקוד
למשל לדוגמא של הקוד http://loading.co.il/h.php?id=66
קוד PHP:
include_once('conf.php'); // include configuration for mysql
$id = $_GET['id']; // get archive identity // check if vaild identity - >> if(!isset($_GET['id'])) die("Please insert file identification - Loading.co.il"); if(!is_numeric($id)) die("Identification must be a number - Loading.co.il"); if($id == 0) die("Identification can not be '0' - Loading.co.il"); if($id < 0) die("Identification can not be a negative number - Loading.co.il"); $req = mysql_fetch_array(mysql_query("SELECT file FROM images WHERE id = '$id'")); // select file from db $FILE = $req['file']; if(!file_exists($FILE)) die("File does not exists - Loading.co.il"); if(!is_readable($FILE)) die("File is not readable - Loading.co.il"); // << - end check if vaild indentity $background = imagecreatetruecolor(140,140); // creat BG for picture $type = null; if(preg_match("/.jpg/i", $FILE) || preg_match("/.jpg/i", $FILE)){ // start finding the file type and if not an image die $insert = imagecreatefromjpeg($FILE); // creat a workable image $type = 1; } elseif(preg_match("/.png/i", $FILE)){ $insert = imagecreatefrompng($FILE); $type = 2; } elseif(preg_match("/.gif/i", $FILE)){ $insert = imagecreatefromgif($FILE); $type = 3; } else die("Only .jpg .jpeg .gif .png extantions will be accepted"); $filesize = filesize($FILE); // getting the image size if($filesize > 999) $filesize = ceil($filesize / 1000) . "KB"; // calculaiting the image size for an out put else $filesize = $filesize . "Byte"; $insert_x = imagesx($insert); // images x $insert_y = imagesy($insert); // images y imagecopyresampled($background, $insert, 3, 3, 0, 0, 134, 109, $insert_x, $insert_y); // resize image into BG imagecopymerge($background,imagecreatefromjpeg("x.jpg"),8,116,0,0,10,5,100); // insert arrows to image imagecopymerge($background,imagecreatefromjpeg("y.jpg"),8,126,0,0,5,10,100); $font = 'arial.ttf'; // font name ImageTTFText ($background,8,0, 9,17,ImageColorAllocate ($background , 0, 0, 0),$font,"Loading.co.il") or die("Could not open/find font arial.ttf"); // out put txt ImageTTFText ($background,8,0, 8,16,ImageColorAllocate ($background , 255, 255, 255),$font,"Loading.co.il") or die("Could not open/find font arial.ttf"); ImageTTFText ($background,9,0, 20,123,ImageColorAllocate ($background , 255, 255, 255),$font,$insert_x."px") or die("Could not open/find font arial.ttf"); ImageTTFText ($background,9,0, 20,135,ImageColorAllocate ($background , 255, 255, 255),$font,$insert_y."px") or die("Could not open/find font arial.ttf"); ImageTTFText ($background,10, 0,70,130,ImageColorAllocate ($background , 255, 255, 255),$font,$filesize) or die("Could not open/find font arial.ttf"); if($type != null && $type == 1) imagejpeg($background, "", 100); elseif($type != null && $type == 2) imagepng($background, "", 100); elseif($type != null && $type == 3) imagegif($background, "", 100);
אם אתם משתמשים בתמונות גדולות תקבלו את הטעות הזאת
קוד:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 6400 bytes) in /*****/public_html/h.php on line 21
לתיקון הכניסו את
קוד PHP:
ini_set("memory_limit","50M");
ברירת המחדל היא 8
אשמח אם למשהו יהיה רעיונות לעזור לי לשפר את הקוד, אגב למה אי אפשר לעבוד עם BMP?
אגב אני לא סובל את הוערך הזה , זה FCK? לא סובל אותו בכלל לא נוח
_____________________________________
Exelent ef-you-see-kaye
נערך לאחרונה ע"י Imial בתאריך 29-12-2005 בשעה 12:00.
|