for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace kalanis\kw_images\Graphics\Format;
use kalanis\kw_images\ImagesException;
use kalanis\kw_images\Interfaces\IIMTranslations;
/**
* Class Xbm
* X BitMap
* @package kalanis\kw_images\Graphics\Format
*/
class Xbm extends AFormat
{
* @param IIMTranslations|null $lang
* @throws ImagesException
public function __construct(?IIMTranslations $lang = null)
$this->setImLang($lang);
if (!function_exists('imagecreatefromxbm') || !function_exists('imagexbm')) {
// @codeCoverageIgnoreStart
throw new ImagesException($this->getImLang()->imImageMagicLibNotPresent(), ImagesException::FORMAT_NO_LIBRARY);
}
// @codeCoverageIgnoreEnd
public function load(string $path)
$result = @imagecreatefromxbm($path);
if (false === $result) {
throw new ImagesException($this->getImLang()->imCannotCreateFromResource(), ImagesException::FORMAT_XBM_CANNOT_LOAD);
return $result;
public function save(?string $path, $resource): void
if (!@imagexbm($resource, $path)) {
throw new ImagesException($this->getImLang()->imCannotSaveResource(), ImagesException::FORMAT_XBM_CANNOT_SAVE);