Why saving image with spatie/image I got error?

41 Views Asked by At

On Laravel 10 site using spatie/image I read file from storage path and making some modifications. I want to save it under other storage path, but I got error when try to save image under storage path

    $this->destPath = '/_wwwroot/lar/NewsPublisher/storage/app/public/photos/RESULTS/RESULT.png';
    // raise error: Unable to create a directory at /storage/app/public/photos.

I tried to write under public/storage subdirectory :

    $this->destPath = '/_wwwroot/lar/NewsPublisher/public/storage/photos/RESULTS/RESULT.png';
    //  raise error: Unable to create a directory at /storage/app/public/photos.

When I try to debug imagePathRef object

dd($this->imagePathRef);

It shows :

Spatie\Image\Image^ {#1083
  #manipulations: Spatie\Image\Manipulations^ {#1084
    #manipulationSequence: Spatie\Image\ManipulationSequence^ {#1085
      #groups: array:1 [
        0 => array:3 [
          "width" => "400"
          "height" => "340"
          "border" => "10,#ff0c75,overlay"
        ]
      ]
    }
  }
  #imageDriver: "gd"
  #temporaryDirectory: null
  #optimizerChain: null
  #pathToImage: "/storage/app/public/photos/KdRLx9YQ6gNsMtqg27fdXjvYqaPJnsSz15PXIaqs.jpg"

With valid pathToImage image I provided

I pass a valid directory path :

/_wwwroot/lar/NewsPublisher/public/storage/photos/RESULTS$ ls -la
total 4
drwxrwxrwx 1 root root    0 feb 28 10:45 .
drwxrwxrwx 1 root root 4096 feb 29 16:59 ..

So I excluded invalid path passed.

What is wrong ?

 "spatie/image": "^2.2.7",
 "laravel/framework": "^10.45.1",
0

There are 0 best solutions below