mirror of
https://github.com/Intervention/image.git
synced 2025-02-06 22:00:38 +01:00
added bmp write support for Imagick driver
This commit is contained in:
parent
f0cc7cc86c
commit
59a76640e2
@ -60,6 +60,13 @@ abstract class AbstractEncoder
|
||||
*/
|
||||
abstract protected function processTiff();
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as BMP string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function processBmp();
|
||||
|
||||
/**
|
||||
* Process a given image
|
||||
*
|
||||
@ -102,6 +109,13 @@ abstract class AbstractEncoder
|
||||
case 'image/tiff':
|
||||
$this->result = $this->processTiff();
|
||||
break;
|
||||
|
||||
case 'bmp':
|
||||
case 'image/bmp':
|
||||
case 'image/x-windows-bmp':
|
||||
case 'image/x-ms-bmp':
|
||||
$this->result = $this->processBmp();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
|
@ -27,7 +27,6 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
switch ($info[2]) {
|
||||
case IMAGETYPE_PNG:
|
||||
$core = imagecreatefrompng($path);
|
||||
// imagepalettetotruecolor($core);
|
||||
$this->gdResourceToTruecolor($core);
|
||||
break;
|
||||
|
||||
@ -37,13 +36,12 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
||||
|
||||
case IMAGETYPE_GIF:
|
||||
$core = imagecreatefromgif($path);
|
||||
// imagepalettetotruecolor($core);
|
||||
$this->gdResourceToTruecolor($core);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
"Unable to read image type. Only use JPG, PNG or GIF images with GD driver."
|
||||
"Unable to read image type. GD driver is only able to decode JPG, PNG or GIF files."
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -66,4 +66,16 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
"TIFF format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as BMP string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processBmp()
|
||||
{
|
||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||
"BMP format is not supported by Gd Driver."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -87,4 +87,22 @@ class Encoder extends \Intervention\Image\AbstractEncoder
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes and returns encoded image as BMP string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function processBmp()
|
||||
{
|
||||
$format = 'bmp';
|
||||
$compression = \Imagick::COMPRESSION_UNDEFINED;
|
||||
|
||||
$imagick = $this->image->getCore();
|
||||
$imagick->setFormat($format);
|
||||
$imagick->setImageFormat($format);
|
||||
$imagick->setCompression($compression);
|
||||
$imagick->setImageCompression($compression);
|
||||
|
||||
return $imagick->getImagesBlob();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user