0

I am working to implement the WideImage plugin on a PHP-based project.

Right now, we have the image upload working (which goes to a temporary folder based on session ID), but no text is written on the image. I was working based off of this example on their website (minus the shadow effect), but it doesn't seem to be doing anything. When I go to the destination folder and look at the uploaded image, there are no changes.

Here is the code snippet; are there any errors that stand out? I recently added the setFont line, but that didn't seem to make a difference.

      require("upload.php");
      $userImagePath = $userFolderPath . $_FILES["fileToUpload"]["name"];

      $newImagePath = null;


      $image = WideImage::loadFromFile($userImagePath);


      $canvas = $image->getCanvas();
      $canvas->setFont('resources/assets/NOVABOLD.otf');


      $canvas->useFont('resources/assets/NOVABOLD.otf', 20, $image->allocateColor(255, 255, 255));          
      $canvas->writeText('center', 'top', 'I am ');

When I use echo $userImagePath, it does give me a working file path.

I've also tried using the fileFromUpload option, but it wouldn't recognize it as an upload even though I gave it the file field's name from the HTML form.

Yami Medina
  • 670
  • 10
  • 26
  • Are you saving the file? Looking at your link the last line should be `$image->saveToFile('image-with-text.jpg');` to save the new image with text – Michael Walton Dec 24 '15 at 03:10
  • @MichaelWalton thanks, that was a simple omission. However, my branch doesn't seem to be accepting the image and uploading it at all :( Error output here: http://pastebin.com/7dFk5YH8 – Yami Medina Dec 24 '15 at 23:22
  • Specifically, it appears to be creating randomly generated folders but no longer leaving any image inside when uploading. It works when WideImage functionality is removed. – Yami Medina Dec 24 '15 at 23:26

1 Answers1

0
  $font = '/resources/assets/NOVABOLD.otf';
  $image = WideImage::load('name');

  $canvas = $image->getCanvas();

  $canvas->useFont($font, 20, $image->allocateColor(255, 255, 255));          
  $canvas->writeText('center', 'top', 'I am ');