Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Manipulating images using PHP, Imagick, and 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' )); ```