/** * determine the size of the image. write size to the database. * copy file to local folder */ function process() { global $c; $delete = $_POST["REMOVE".$this->fkid]; if ($delete) { addUpdate("pgn_image", "FILENAME", "", "FKID = ".$this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", 0, "FKID = ".$this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", 0, "FKID = ".$this->fileId, "NUMBER"); } else { // check, if upload. if ($this->suffix != "") { $image = $_FILES[$this->name]['tmp_name']; $image_name = $_FILES[$this->name]['name']; //determine image size $size = getimagesize($image); $width = $size[0]; $height = $size[1]; $oldfilename = getDBCell("pgn_image", "FILENAME", "FKID = " . $this->fileId); $filename = $this->fileId . "." . $this->suffix; // updating the database addUpdate("pgn_image", "FILENAME", $filename, "FKID = " . $this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", $width, "FKID = " . $this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", $height, "FKID = " . $this->fileId, "NUMBER"); // loading up new item. if ($oldfile != "") unlink ($c["devfilespath"] . $oldfilename); move_uploaded_file($image, $c["devfilespath"] . $filename); nxCopy($c["devfilespath"] . $filename, $c["devfilespath"], "orig_".$filename); // setting variables for further filtering $this->filename = $filename; $this->width = $width; $this->height = $height; // try creating thumbnails if ($c["useimagemagick"]) { $thumb = new NXImageApi($c["devfilespath"].$filename, $c["devfilespath"]."t".$filename); $thumb->resizeAbsolute(120, 120); $thumb->gravity = "Center"; $thumb->drawText("Preview"); $thumb->save(); $this->applyAutoMod($filename); } else { $thumb = new Img2Thumb($c["devfilespath"].$filename, 120, 120, $c["devfilespath"]."t".$filename); } //determine image size $size = getimagesize($c["devfilespath"] . $filename); $width = $size[0]; $height = $size[1]; $oldfilename = getDBCell("pgn_image", "FILENAME", "FKID = " . $this->fileId); $filename = $this->fileId . "." . $this->suffix; // updating the database addUpdate("pgn_image", "FILENAME", $filename, "FKID = " . $this->fileId, "TEXT"); addUpdate("pgn_image", "WIDTH", $width, "FKID = " . $this->fileId, "NUMBER"); addUpdate("pgn_image", "HEIGHT", $height, "FKID = " . $this->fileId, "NUMBER"); } } }
/** * create the image * @param string Name and path of the image to create */ function createImage($imagename) { global $panic, $debug; $content = getDBCell("pgn_label", "CONTENT", "FKID = $this->fkid"); $image = new NXImageApi("", $imagename, false); $image->createCanvas($this->getOption("NUMBER2"),$this->getOption("NUMBER3"), $this->getOption("TEXT3")); $image->font = $this->getOption("TEXT4"); $image->fontsize = $this->getOption("NUMBER1"); $image->fontstyle = $this->getOption("TEXT5"); $image->gravity = $this->getOption("TEXT1"); $image->fillcolor = $this->getOption("TEXT2"); $image->drawText($content, 0, 0); $image->save(); }
/** * Paints a text as image. * All configuration variables must be set before! * @param string TExt to paint * @param integer Offset on X-Axis * @param integer Offset on Y-Axis */ function paint($text, $x=0, $y=0) { global $cds; $name = $this->getImageName($text); if ($name != "") { $image = new NXImageApi("", $cds->path."images/".$name, false); $image->createCanvas($this->width, $this->height, $this->bgcolor); $image->font = $this->font; $image->fontsize = $this->fontsize; $image->gravity = $this->gravity; $image->fillcolor = $this->textcolor; $image->fontstyle = $this->fontstyle; $image->drawText($text, $x, $y); $image->save(); } return '<img src="'.$cds->docroot.'images/'.$this->getImageName2($text).'" width="'.$this->width.'" height="'.$this->height.'" alt="'.$text.'" border="0">'; }