I'm trying to write text on an image it works fine on local systems, but when I get it on the server My code does not work for live upload
$ imgpath = base_url () "public / images / mix / theatre.jpg"; $ Jpg_image = imagecreatefromjpeg ($ imgPath); // assign a color for text $ color = imagecolorallocate ($ jpg_image, 102, 20, 99); // set the path to the font file $ font_path = FCPATH "public / fonts / myriad pro.TTF"; // resonant $ font_path = base_url (). "/ Public / fonts / myriad pro.TTF"; // Set text to be printed on text $ text = "Now showing"; // Image on print $ imagettf = imagettftext ($ jpg_image, 16, 0, 57, 140, $ color, $ font_path, $ text); $ SendImage = imagejpeg ($ jpg_image, $ saveToPath); Var_dump ($ savedImage);
This gives me the same image I copied from $ imgpath
, the text is not written on it
You can use this code
& lt ;? Php header ('content-type: image / png'); $ Im = imagecreatefromjpeg ('include / dir / something.jpg'); $ Black = imagecolorallocate ($ im, 0, 0, 0); $ Text = strotler ("show now"); $ Font = '/ dir / some.TTF included'; False image ($ im, 25, 0, 15, 33, $ black, $ font, $ text); Imagepng ($ im); Imagedestroy ($ im); ? & Gt;
Its work for me
Comments
Post a Comment