Imagick::functionImage
← frameImage
fxImage →
This method is available if Imagick has been compiled against ImageMagick version 6.4.9 or newer.
FunctionImage applies one of the following functions to an image: Polynomial, Sinusoid, Arctan, Arcsin to generate a gradient image with varying intensity. The image below shows the generated gradient, and an analysis of the image generated (the red line) to make it easier to see the gradient
FUNCTION_SINUSOID Intensity = f3 * sin(f1 * (x + f2)) + f4
value = amplitude * sin(2*PI( freq*value + phase/360 ) ) + bias
f1 - Frequency of wave
f2 - Start angle, default = 0
f3 - Amplitude, default = 0.5
f4 - Constant waves are applied to, default = 0.5
Example 1 - Polynomial
$imagick = new \Imagick();
$imagick->newPseudoImage(500, 500, 'gradient:black-white');
$arguments = array(
$this->functionImageControl->getFirstTerm(),
);
$secondTerm = $this->functionImageControl->getSecondTerm();
$thirdTerm = $this->functionImageControl->getThirdTerm();
$fourthTerm = $this->functionImageControl->getFourthTerm();
if (strlen($secondTerm)) {
$arguments[] = $secondTerm;
if (strlen($thirdTerm)) {
$arguments[] = $thirdTerm;
if (strlen($fourthTerm)) {
$arguments[] = $fourthTerm;
}
}
}
$imagick->functionImage(\Imagick::FUNCTION_POLYNOMIAL, $arguments);
$imagick->setimageformat('png');
Image::analyzeImage($imagick, 512, 256);
Example 2 - Sinusoid
$imagick = new \Imagick();
$imagick->newPseudoImage(500, 500, 'gradient:black-white');
$arguments = array(
$this->functionImageControl->getFirstTerm(),
);
$secondTerm = $this->functionImageControl->getSecondTerm();
$thirdTerm = $this->functionImageControl->getThirdTerm();
$fourthTerm = $this->functionImageControl->getFourthTerm();
if (strlen($secondTerm)) {
$arguments[] = $secondTerm;
if (strlen($thirdTerm)) {
$arguments[] = $thirdTerm;
if (strlen($fourthTerm)) {
$arguments[] = $fourthTerm;
}
}
}
$imagick->functionImage(\Imagick::FUNCTION_SINUSOID, $arguments);
$imagick->setimageformat('png');
Image::analyzeImage($imagick, 512, 256);
Example 3 - ArcTan
$imagick = new \Imagick();
$imagick->newPseudoImage(500, 500, 'gradient:black-white');
$arguments = array(
$this->functionImageControl->getFirstTerm(),
);
$secondTerm = $this->functionImageControl->getSecondTerm();
$thirdTerm = $this->functionImageControl->getThirdTerm();
$fourthTerm = $this->functionImageControl->getFourthTerm();
if (strlen($secondTerm)) {
$arguments[] = $secondTerm;
if (strlen($thirdTerm)) {
$arguments[] = $thirdTerm;
if (strlen($fourthTerm)) {
$arguments[] = $fourthTerm;
}
}
}
$imagick->functionImage(\Imagick::FUNCTION_ARCTAN, $arguments);
$imagick->setimageformat('png');
Image::analyzeImage($imagick, 512, 256);
Example 4 - ArcSin
$imagick = new \Imagick();
$imagick->newPseudoImage(500, 500, 'gradient:black-white');
$arguments = array(
$this->functionImageControl->getFirstTerm(),
);
$secondTerm = $this->functionImageControl->getSecondTerm();
$thirdTerm = $this->functionImageControl->getThirdTerm();
$fourthTerm = $this->functionImageControl->getFourthTerm();
if (strlen($secondTerm)) {
$arguments[] = $secondTerm;
if (strlen($thirdTerm)) {
$arguments[] = $thirdTerm;
if (strlen($fourthTerm)) {
$arguments[] = $fourthTerm;
}
}
}
$imagick->functionImage(\Imagick::FUNCTION_ARCSIN, $arguments);
$imagick->setimageformat('png');
Image::analyzeImage($imagick, 512, 256);