clownfish/client

Image scaling with AWS S3 and Lambda

dev-master 2017-05-15 06:53 UTC

This package is not auto-updated.

Last update: 2024-04-22 12:52:30 UTC


README

usage

$secret = 'sharedsecret';
$s3 = 'imghosting-foo';
$cloudfrontRoot = 'https://d2rrvpvpaaof6s.cloudfront.net';

// pass bucket name and region. credentials optional.
$service = new Clownfish\Service($s3, 'ap-southeast-1', ['key' => 'foo', 'secret' => 'bar']);

// upload image
$image = $service->uploadImage('foo.jpg', 'article', 1);

// originalFilename is your reference with which you can recreate the Image Object
$originalFilename = $image->getFilename();

// output scaled version
$image = new Clownfish\Image($originalFilename);

$scaledImage = $image->getScaledImage(100, 100, $secret);

$scaledUrl = $cloudfrontRoot . $scaledImage->getPath();

echo $scaledUrl."\n";