public function memedecode($id, $meme_id, $first_line, $second_line) { try { $image = Meme::findOrFail($meme_id); $meme = MemeInstance::findOrFail($id); } catch (Exception $e) { App::abort('404'); } if (file_exists(PUBLIC_DIR . $image->img)) { $font = PUBLIC_DIR . 'assets/font/impact.ttf'; $img = imagecreatefromjpeg(PUBLIC_DIR . $image->img); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); MemeGenerator::imagettftextoutline($img, 20, 0, 10, 45, $white, $black, $font, Trans::_t(mb_strtoupper(htmlspecialchars_decode(urldecode($meme->first_line)))), 2, 'up'); MemeGenerator::imagettftextoutline($img, 20, 0, 10, 95, $white, $black, $font, Trans::_t(mb_strtoupper(htmlspecialchars_decode(urldecode($meme->second_line)))), 2, 'down'); ob_start(); imagejpeg($img); $data = base64_encode(ob_get_clean()); } header("Content-Type: image/jpeg"); echo base64_decode($data); //return Response::make("data:image/jpg;base64,".$data, 200, array('content-type' => 'image/jpg')); }
$finalOutput = $brokenText[$i]; $textHeight += 13; } //if this is the last word append this also.The previous if will be true if the last word will have no room if ($i == count($brokenText) - 1) { $dimensions = $this->GetFontPlacementCoordinates($finalOutput, 10); $locx = $this->getHorizontalTextAlignment($this->imgSize[0], $dimensions[4]); $this->PlaceTextOnImage($this->im, 10, $locx, $textHeight, $this->font, $finalOutput); } } return $finalOutput; } public function processImg() { if ($this->lowerText != "") { $this->WorkOnImage($this->lowerText, 30, "lower"); } if ($this->upperText != "") { $this->WorkOnImage($this->upperText, 30, "upper"); } imagejpeg($this->im, "abc.jpg"); imagedestroy($this->im); echo "abc.jpg"; } } $obj = new MemeGenerator('testing.jpg'); $upmsg = $_GET['upmsg']; $downmsg = $_GET['downmsg']; $obj->setUpperText($upmsg); $obj->setLowerText($downmsg); $obj->processImg();