Adding the imagick extension to Bref

Recently the ‘GD’ extension was added to Bref, allowing images to be created.

Continuing on that theme, the ‘imagick’ extension was also going to be a nice addition.

To add it in, you need to do the following;

  1. Checkout bref from Github
  2. Add in the lines suggested here, into the ‘runtimes/php-intermediary.Dockerfile’;
  3. Go into the ‘runtimes’ dir and run ‘make layers’

This will make a few zip files in the ‘runtimes/export’ dir, which are the layers (runtimes) which need to be uploaded to Lambda. That can be done by;

aws lambda publish-layer-version --region=ap-southeast-2 --layer-name=php-73-fpm-with-imagick --zip-file fileb:// --compatible-runtimes provided --output text
aws lambda publish-layer-version --region=ap-southeast-2 --layer-name=php-73-with-imagick --zip-file fileb:// --compatible-runtimes provided --output text

Don’t forget to change the region name in the above commands!

Once that’s done, you’ll see the layers in the ‘Lambda’ ‘Layers’ page. Copy the ARN from there into your serverless .yml file, and away you go!

Don’t forget to enable the extension – this is done by creating a ‘php.ini’ file at /php/conf.d/php.ini (in your code-base), with the following;


If you want to make sure it works, include the following in your PHP file and it’ll output a full list of info about the PHP environment, including a section on imagick if it’s been enabled & setup properly.


Leave a Reply