mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 16:50:07 +02:00
added bmp write support for Imagick driver
This commit is contained in:
@@ -60,6 +60,13 @@ abstract class AbstractEncoder
|
|||||||
*/
|
*/
|
||||||
abstract protected function processTiff();
|
abstract protected function processTiff();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes and returns encoded image as BMP string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract protected function processBmp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a given image
|
* Process a given image
|
||||||
*
|
*
|
||||||
@@ -103,6 +110,13 @@ abstract class AbstractEncoder
|
|||||||
$this->result = $this->processTiff();
|
$this->result = $this->processTiff();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'bmp':
|
||||||
|
case 'image/bmp':
|
||||||
|
case 'image/x-windows-bmp':
|
||||||
|
case 'image/x-ms-bmp':
|
||||||
|
$this->result = $this->processBmp();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \Intervention\Image\Exception\NotSupportedException(
|
throw new \Intervention\Image\Exception\NotSupportedException(
|
||||||
"Encoding format ({$format}) is not supported."
|
"Encoding format ({$format}) is not supported."
|
||||||
|
@@ -27,7 +27,6 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
|||||||
switch ($info[2]) {
|
switch ($info[2]) {
|
||||||
case IMAGETYPE_PNG:
|
case IMAGETYPE_PNG:
|
||||||
$core = imagecreatefrompng($path);
|
$core = imagecreatefrompng($path);
|
||||||
// imagepalettetotruecolor($core);
|
|
||||||
$this->gdResourceToTruecolor($core);
|
$this->gdResourceToTruecolor($core);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -37,13 +36,12 @@ class Decoder extends \Intervention\Image\AbstractDecoder
|
|||||||
|
|
||||||
case IMAGETYPE_GIF:
|
case IMAGETYPE_GIF:
|
||||||
$core = imagecreatefromgif($path);
|
$core = imagecreatefromgif($path);
|
||||||
// imagepalettetotruecolor($core);
|
|
||||||
$this->gdResourceToTruecolor($core);
|
$this->gdResourceToTruecolor($core);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \Intervention\Image\Exception\NotReadableException(
|
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."
|
"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();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user