function Cartoonfy($p_image, $p_triplevel, $p_diffspace) { $this->triplevel = (int) (2000.0 + 5000.0 * $p_triplevel); $this->diffspace = (int) ($p_diffspace * 32.0); $this->i0 = imageCreateFromString(file_get_contents($p_image)); if ($this->i0) { $this->i1 = imageCreateTrueColor(imageSx($this->i0), imageSy($this->i0)); for ($x = (int) $this->diffspace; $x < imageSx($this->i0) - (1 + (int) $this->diffspace); $x++) { for ($y = (int) $this->diffspace; $y < imageSy($this->i0) - (1 + (int) $this->diffspace); $y++) { $t = Cartoonfy::GetMaxContrast($x, $y); if ($t > $this->triplevel) { imageSetPixel($this->i1, $x, $y, 0); } else { imageSetPixel($this->i1, $x, $y, Cartoonfy::FlattenColor(imageColorAt($this->i0, $x, $y))); } } //usleep(1000); } imageDestroy($this->i0); } else { print "<b>" . $p_image . "</b> is not supported image format!"; exit; } }