Question

Manipulating images using PHP, Imagick, and Spaces

Posted August 6, 2021 82 views
PHPDigitalOcean Spaces

Having trouble manipulating images with Imagick. My environment is Ubuntu 20.04, PHP 7.4, and mySQL 8.0.2.

I am retrieving user generated images from the spaces storage, then manipulating the images, then attempting to store them back to the spaces storage. The issue is, the images are not being stored in the spaces server after manipulation. The occupied memory (in Spaces storage)increases, but there are no manipulated images present.
Why is this happening? How can I manipulate images and store them in spaces using PHP and Imagick.

   $s3_object = new S3Client([
        'version' => 'version',
        'region'  => 'region',
        'endpoint' => 'endpoint',
        'credentials' => [
            'key'    => 'KEY',
            'secret' => 'SECRET KEY',
        ],
     ]);
            $image_object =  new Imagick();
            $image_object->readImageBlob(base64_decode($imageData));
                                                                         $image_object->setImageCompression(Imagick::COMPRESSION_JPEG);
             $image_object->setImageCompressionQuality((int) $compressionQuality);

          $result = $client->putObject( array(

            'Bucket' => $bucket ,
            'Key' => $path . $imageNameFull,
            'Body' => $image_object->getimageblob(),
            'ACL' => 'public-read',
            'ContentType' => 'image/jpeg'
        ));
    ```
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!