private function _applyLetterbox(\Imagine\Image\ImageInterface &$imageInstance, $transform)
{
if (isset($transform['width']) and isset($transform['height'])) {
// if both isn't set, there's no need for a letterbox
$letterboxDef = $this->getSetting('letterbox', $transform);
$size = new \Imagine\Image\Box($transform['width'], $transform['height']);
$position = new \Imagine\Image\Point(floor(((int) $transform['width'] - $imageInstance->getSize()->getWidth()) / 2), floor(((int) $transform['height'] - $imageInstance->getSize()->getHeight()) / 2));
$palette = new \Imagine\Image\Palette\RGB();
$color = $palette->color(isset($letterboxDef['color']) ? $letterboxDef['color'] : '#000', isset($letterboxDef['opacity']) ? (int) ($letterboxDef['opacity'] * 100) : 0);
$backgroundImage = $this->imagineInstance->create($size, $color);
$backgroundImage->paste($imageInstance, $position);
$imageInstance = $backgroundImage;
}
}