/**
   Creating a Function which take an Animated Gif Image and Convert into Still image 
 */
 public static function create_frame_from_animated_pic($img_input_path, $picture, $img_output_path, $max_x, $max_y, $new_image_name = False)
 {
     Logger::log("create_frame_from_animated_pic({$img_input_path}, {$picture}, {$img_output_path}, {$max_x}, {$max_y}, {$new_image_name})");
     // for Retriving the Original Name of file
     $temp_name = explode('/', $picture);
     $temp_name = $temp_name['1'];
     if (!empty($temp_name)) {
         $name = explode('.', $temp_name);
         $file_name = $name['0'];
         // if it's a .gif image
         if (preg_match("/\\.gif\$/i", $temp_name)) {
             $img_input_path = $img_input_path . '/files/';
             $image_full_path = $img_input_path . $temp_name;
             $new_image = $file_name;
             // creating the object of the Gifsplit class and initializing the Contructor
             $sg = new GifSplit($image_full_path, 'GIF', $new_image, $img_input_path);
             if ($sg->getReport() == 'ok') {
                 return TRUE;
             }
         }
         return FALSE;
     }
 }
 function processForm(&$form)
 {
     $delete = "";
     $compositeFields = array();
     $ignoreList = array();
     foreach ($form as $key => $value) {
         if (array_key_exists($key, $ignoreList)) {
             continue;
         }
         if (get_magic_quotes_gpc() && !defined("SLASHES_KILLED")) {
             $value = stripslashes($value);
         }
         if ($key[0] == "/" && !strpos($key, "#")) {
             $this->_saveField($key, $value, TRUE);
         } else {
             if (preg_match('/sb_action_add_row(.+)/', $key, $result)) {
                 $field = $result[1];
                 $paths = explode("/", $field);
                 $nodeName = array_pop($paths);
                 $path = implode("/", $paths);
                 $this->_checkAndCreatePath($field);
                 $this->instance->appendElement($path, $nodeName);
             } else {
                 if (preg_match('/sb_action_delete_row(.+)/', $key, $result)) {
                     // queue the delete action so that it can execute after the document
                     // is complete.
                     $delete = $this->_decodeFieldName($result[1]);
                 } else {
                     if (sizeof($_FILES) > 0 && $key == 'sb_mc_type') {
                         foreach ($_FILES as $uploadkey => $file_details) {
                             preg_match('/sb_action_upload_file_name(.+)/', $uploadkey, $result);
                             if ($file_details['error'] == 0) {
                                 $uploadfile = $this->fileUploadDirectory . "/" . time() . basename($_FILES[$uploadkey]['name']);
                                 if (copy($_FILES[$uploadkey]['tmp_name'], $uploadfile)) {
                                     // Code for Extracting Frames from SBconetnts
                                     if ($_FILES[$uploadkey]['type'] == 'image/gif') {
                                         // For retriving the ext and the file name of the file
                                         $name = explode('/', $uploadfile);
                                         $temp_name = $name[count($name) - 1];
                                         $name = explode('.', $temp_name);
                                         $file_ext = $name[1];
                                         $file_name = $name[0];
                                         // if the image is Gif
                                         if (strtolower($file_ext) == 'gif') {
                                             $new_image = $file_name;
                                             // creating the object of the Gifsplit class and initializing the Contructor
                                             $sg = new GifSplit($uploadfile, 'GIF', $new_image, $this->fileUploadDirectory . "/");
                                             if ($sg->getReport() == 'ok') {
                                                 // We can extend this for other jpeg animated images
                                                 // Also we can do exception handling here
                                             }
                                         }
                                     }
                                     $value = $this->fileUploadURL . "/" . time() . $_FILES[$uploadkey]['name'];
                                     // Save the URL to the uploaded resource
                                     $this->_saveField($result[1], $value, TRUE);
                                     $ignoreList[$result[1]] = 1;
                                     // we don't want the URL to be overwritten by the hidden field containing the last URL
                                 } else {
                                     //FIXME: failed to upload the file - report an error?
                                 }
                             }
                         }
                     } else {
                         if ($key[0] == "/" && strpos($key, "#") > 0) {
                             $pieces = explode("#", $key);
                             $field = $pieces[0];
                             $attribute = $pieces[1];
                             // This creates a hash structure keyed off the field name with a sub hash containing
                             // the attributes
                             $compositeFields[$field][$attribute] = $value;
                         }
                     }
                 }
             }
         }
     }
     // Save the composite fields by looking up the type and then building the value
     if (count($compositeFields) > 0) {
         // there can be multiple fields with components in the form
         foreach ($compositeFields as $field => $components) {
             // Find out the type of the field
             $type = $components['type'];
             if ($type) {
                 $renderer = $this->_getRenderer($type);
                 $value = $renderer->getValueFromComponents($components);
                 // Save the field to the XML structure.
                 $this->_saveField($field, $value, TRUE);
             }
         }
     }
     // Add one last field to the data to encode the type.
     $this->_saveField("/node()/@type", $this->type, TRUE);
     // Delete the row queued earlier. We can only safely delete one row per
     // transaction as the indexes will shift around after the first delete.
     // TODO: an altenate way to do this would be to look at the fields while
     // building the document and then drop any that match paths under delete keys.
     if ($delete) {
         $this->instance->removeChild($delete);
     }
 }