mirror of
https://github.com/Imagick/imagick.git
synced 2026-06-19 07:35:36 +00:00
Add Imagick::addNoiseImageWithAttenuate
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
3.6.0RC2
|
||||
- Fixes:
|
||||
* Remove deprecated message from Imagick::roundCorners()
|
||||
- Added:
|
||||
* Imagick::addNoiseImageWithAttenuate()
|
||||
|
||||
3.6.0RC1
|
||||
- Imagick::getImageInterlaceScheme is undeprecated. It's the appropriate function to call to get the image interlace setting.
|
||||
- Image formats are now normalised to lower case.
|
||||
|
||||
@@ -676,6 +676,14 @@ class Imagick
|
||||
// NOISE_*
|
||||
public function addNoiseImage(int $noise, int $channel = Imagick::CHANNEL_DEFAULT): bool {}
|
||||
|
||||
#if IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
public function addNoiseImageWithAttenuate(
|
||||
int $noise,
|
||||
float $attenuate,
|
||||
int $channel = Imagick::CHANNEL_DEFAULT
|
||||
): bool {}
|
||||
#endif
|
||||
|
||||
public function motionBlurImage(
|
||||
float $radius,
|
||||
float $sigma,
|
||||
|
||||
@@ -3155,6 +3155,30 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_addNoiseImage, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, channel, IS_LONG, 0, "Imagick::CHANNEL_DEFAULT")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#if IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
|
||||
#if PHP_VERSION_ID >= 80000
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_addNoiseImageWithAttenuate, 0, 2, _IS_BOOL, 0)
|
||||
#else
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Imagick_addNoiseImageWithAttenuate, 0, 0, 2)
|
||||
#endif
|
||||
|
||||
|
||||
#if PHP_VERSION_ID >= 80000
|
||||
ZEND_ARG_TYPE_INFO(0, noise, IS_LONG, 0)
|
||||
#else
|
||||
ZEND_ARG_INFO(0, noise)
|
||||
#endif
|
||||
|
||||
#if PHP_VERSION_ID >= 80000
|
||||
ZEND_ARG_TYPE_INFO(0, attenuate, IS_DOUBLE, 0)
|
||||
#else
|
||||
ZEND_ARG_INFO(0, attenuate)
|
||||
#endif
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, channel, IS_LONG, 0, "Imagick::CHANNEL_DEFAULT")
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
|
||||
#if PHP_VERSION_ID >= 80000
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Imagick_motionBlurImage, 0, 3, _IS_BOOL, 0)
|
||||
@@ -6090,6 +6114,9 @@ ZEND_METHOD(Imagick, queryFonts);
|
||||
ZEND_METHOD(Imagick, queryFontMetrics);
|
||||
ZEND_METHOD(Imagick, steganoImage);
|
||||
ZEND_METHOD(Imagick, addNoiseImage);
|
||||
#if IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
ZEND_METHOD(Imagick, addNoiseImageWithAttenuate);
|
||||
#endif
|
||||
ZEND_METHOD(Imagick, motionBlurImage);
|
||||
#if MagickLibVersion < 0x700 && !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
|
||||
ZEND_METHOD(Imagick, mosaicImages);
|
||||
@@ -6815,6 +6842,9 @@ static const zend_function_entry class_Imagick_methods[] = {
|
||||
ZEND_ME(Imagick, queryFontMetrics, arginfo_class_Imagick_queryFontMetrics, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Imagick, steganoImage, arginfo_class_Imagick_steganoImage, ZEND_ACC_PUBLIC)
|
||||
ZEND_ME(Imagick, addNoiseImage, arginfo_class_Imagick_addNoiseImage, ZEND_ACC_PUBLIC)
|
||||
#if IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
ZEND_ME(Imagick, addNoiseImageWithAttenuate, arginfo_class_Imagick_addNoiseImageWithAttenuate, ZEND_ACC_PUBLIC)
|
||||
#endif
|
||||
ZEND_ME(Imagick, motionBlurImage, arginfo_class_Imagick_motionBlurImage, ZEND_ACC_PUBLIC)
|
||||
#if MagickLibVersion < 0x700 && !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
|
||||
ZEND_ME(Imagick, mosaicImages, arginfo_class_Imagick_mosaicImages, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
|
||||
|
||||
@@ -10379,6 +10379,41 @@ PHP_METHOD(Imagick, addNoiseImage)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
#if IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
/* {{{ proto bool Imagick::addNoiseImageWithAttenuate(int noise_type, float attenuate[, int channel])
|
||||
Adds random noise to the image.
|
||||
*/
|
||||
PHP_METHOD(Imagick, addNoiseImageWithAttenuate)
|
||||
{
|
||||
php_imagick_object *intern;
|
||||
MagickBooleanType status;
|
||||
im_long noise;
|
||||
im_long channel = IM_DEFAULT_CHANNEL;
|
||||
double attenuate;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld|l", &noise, &attenuate, &channel) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
intern = Z_IMAGICK_P(getThis());
|
||||
|
||||
if (php_imagick_ensure_not_empty (intern->magick_wand) == 0)
|
||||
return;
|
||||
|
||||
|
||||
status = MagickAddNoiseImageChannel(intern->magick_wand, channel, noise);
|
||||
|
||||
if (status == MagickFalse) {
|
||||
php_imagick_convert_imagick_exception(intern->magick_wand, "Unable to add image noise" TSRMLS_CC);
|
||||
return;
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif //IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE
|
||||
|
||||
/* {{{ proto Imagick Imagick::montageImage(ImagickDraw drawing_wand, string tile_geometry, string thumbnail_geometry, int mode, string frame)
|
||||
Creates a composite image by combining several separate images. The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile.
|
||||
*/
|
||||
|
||||
@@ -98,6 +98,10 @@
|
||||
#define IM_HAVE_IMAGICK_WHITEBALANCEIMAGE 1
|
||||
#endif
|
||||
|
||||
#if MagickLibVersion >= 0x702
|
||||
#define IM_HAVE_IMAGICK_ADD_NOISE_WITH_ATTENUATE 1
|
||||
#endif
|
||||
|
||||
#if MagickLibVersion >= 0x70A
|
||||
// Technically, this may be available earlier, but the behaviour around
|
||||
// default mask changed.
|
||||
|
||||
+20
-10
@@ -19,16 +19,6 @@
|
||||
#include "php_imagick_helpers.h"
|
||||
#include "php_imagick_file.h"
|
||||
|
||||
//derprecated
|
||||
|
||||
//MagickReduceNoiseImage
|
||||
//MagickMedianFilterImage
|
||||
//MagickRecolorImage
|
||||
|
||||
//Mising
|
||||
//MagickSetImageBias
|
||||
//MagickSetImageClipMask
|
||||
|
||||
|
||||
#if MagickLibVersion >= 0x700
|
||||
|
||||
@@ -86,6 +76,26 @@ MagickBooleanType MagickAddNoiseImageChannel(MagickWand *wand,const ChannelType
|
||||
return status;
|
||||
}
|
||||
|
||||
// This is not actually an ImageMagick function, but the name is likely to
|
||||
// avoid any symbol clash for the foreseeable.
|
||||
MagickBooleanType MagickAddNoiseImageChannelWithAttenuate(MagickWand *wand,const ChannelType channel,const NoiseType noise_type, double attenuate) {
|
||||
MagickBooleanType status;
|
||||
ChannelType previous_channel_mask;
|
||||
|
||||
if (channel != UndefinedChannel) {
|
||||
previous_channel_mask = MagickSetImageChannelMask(wand, channel);
|
||||
}
|
||||
|
||||
status = MagickAddNoiseImage(wand, noise_type, attenuate);
|
||||
|
||||
if (channel != UndefinedChannel) {
|
||||
(void) MagickSetImageChannelMask(wand, previous_channel_mask);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
MagickBooleanType MagickAutoGammaImageChannel(MagickWand *wand, const ChannelType channel) {
|
||||
MagickBooleanType status;
|
||||
ChannelType previous_channel_mask;
|
||||
|
||||
@@ -43,6 +43,14 @@ MagickBooleanType MagickAddNoiseImageChannel(
|
||||
const ChannelType channel,
|
||||
const NoiseType noise_type
|
||||
);
|
||||
|
||||
MagickBooleanType MagickAddNoiseImageChannelWithAttenuate(
|
||||
MagickWand *wand,
|
||||
const ChannelType channel,
|
||||
const NoiseType noise_type,
|
||||
double attenuate
|
||||
);
|
||||
|
||||
MagickBooleanType MagickAutoGammaImageChannel(MagickWand *wand,
|
||||
const ChannelType channel);
|
||||
MagickBooleanType MagickAutoLevelImageChannel(MagickWand *wand,
|
||||
|
||||
@@ -8,7 +8,7 @@ require_once(dirname(__FILE__) . '/skipif.inc');
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$noiseType = 2;
|
||||
$noiseType = Imagick::NOISE_IMPULSE;
|
||||
$channel = Imagick::CHANNEL_DEFAULT;
|
||||
|
||||
function addNoiseImage($noiseType, $channel) {
|
||||
@@ -19,7 +19,15 @@ function addNoiseImage($noiseType, $channel) {
|
||||
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
|
||||
}
|
||||
|
||||
addNoiseImage($noiseType, $channel) ;
|
||||
function addNoiseImageWithAttenuate($noiseType, $channel) {
|
||||
$imagick = new \Imagick();
|
||||
$imagick->newPseudoImage(640, 480, "magick:logo");
|
||||
$imagick->addNoiseImageWithAttenuate($noiseType, 1.4, $channel);
|
||||
$bytes = $imagick->getImageBlob();
|
||||
if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
|
||||
}
|
||||
|
||||
addNoiseImage($noiseType, $channel);
|
||||
echo "Ok";
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Reference in New Issue
Block a user