note 108253 added to imagick.charcoalimage
| From: | holdoffhunger at gmail dot com | Date: | Wed, 11 Apr 2012 23:13:45 +0000 |
| Subject: | note 108253 added to imagick.charcoalimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187063@lists.php.net to get a copy of this message | ||
The parameters for this function are really scary. Radius of the Gaussian and Standard Deviation of
the Gaussian? After playing with it for a little bit, I think I put it together. The Gaussian is
the "brush" (in Gimp/Photoshop jargin), the radius is simply the radius of the brush, and
the standard deviation is the level of variation among the sizes of the brush imprints. The $radius
parameter can be anything from 0 to as high a number as you can think, but once you beyond 10, 20,
or 30 pixels, depending on the image size, the whole image gets blurred beyond useful recognition.
The $sigma, being the standard deviation, should be smaller than your radius to get the desired
effect. Think of it as "Charcoal Brushes of $radius Pixels Size, with each brush being as much
as $sigma Pixels bigger or smaller than that."
For an average 500 x 500 pixel image, you'll probably want a $radius of 3 to 5 and a $sigma of
1 to 3, but you can go as far as 10 pixels generally before the image is blurred beyond recognition.
(At the moment, $radius: 5 / $sigma: 2 is the perfect blend for this 400x400 image that I'm
working on right now.)
There was not too help from the official documentation site for this project, either: http://www.imagemagick.org/RMagick/doc/image1.html
. The authors there note: "You can alter the intensity of the effect by changing the radius
and sigma arguments." So, my description here of the functioning is based mostly on experience
rather than documentation, which is difficult to find.
The following is the entire code for applying the effect to an image. This code will open the
specified file, it will apply the charcoalImage effect to it, and then it will save it to another
specified file. The arguments are served up through POST data, and the only functions of the
ImageMagick class that are used are the readImageFile, charcoalImage, and writeImageFile, as so :
<?php
// Author: holdoffhunger@gmail.com
// Grab Inbound Data -- Function Parameters
// --------------------------------------------------
$inbound_gaussian_radius = $_POST['radius_of_gaussian'];
$inbound_standard_deviation = $_POST['standard_deviation_of_gaussian'];
// Grab Inbound Data -- Read-File and Write-File
// --------------------------------------------------
$filename_for_function = $_POST['file_target'];
$inbound_save_as_filename = $_POST['saveable_result_file'];
// Grab Image File Data
// ---------------------------------------------
$folder_location = "images/workshop/";
$file_to_grab_with_location = $folder_location . $filename_for_function;
$imagick_type = new Imagick();
// Open File
// ---------------------------------------------
$file_handle_for_viewing_image_file = fopen($file_to_grab_with_location, 'a+');
// Read File
// ---------------------------------------------
$imagick_type->readImageFile($file_handle_for_viewing_image_file);
// Perform Function
// ---------------------------------------------
$imagick_type->charcoalImage($inbound_gaussian_radius, $inbound_standard_deviation);
// Save File
// ---------------------------------------------
$folder_location = "images/workshop/";
$file_to_grab_with_location = $folder_location . $inbound_save_as_filename;
$file_handle_for_saving_image_file = fopen($file_to_grab_with_location, 'a+');
// Write File
// ---------------------------------------------
$imagick_type->writeImageFile($file_handle_for_saving_image_file);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 68.9.137.178
----
Manual Page -- http://www.php.net/manual/en/imagick.charcoalimage.php
Edit -- https://master.php.net/note/edit/108253
Del: integrated -- https://master.php.net/note/delete/108253/integrated
Del: useless -- https://master.php.net/note/delete/108253/useless
Del: bad code -- https://master.php.net/note/delete/108253/bad+code
Del: spam -- https://master.php.net/note/delete/108253/spam
Del: non-english -- https://master.php.net/note/delete/108253/non-english
Del: in docs -- https://master.php.net/note/delete/108253/in+docs
Del: other reasons-- https://master.php.net/note/delete/108253
Reject -- https://master.php.net/note/reject/108253
Search -- https://master.php.net/manage/user-notes.php