title: How to convert GIF image to an static JPG image in Wordpress
body: <p>So i have a form to upload GIFs images and i would like to keep the Animated GIF IMAGE and convert/create a new one static image from the GIF(getting the first frame) to JPG.</p>
  
  <p>This is my form:</p>
  
  <pre><code>&lt;form action="" id="primaryPostForm" method="POST" enctype="multipart/form-data"&gt;
  
          &lt;fieldset&gt;
      &lt;p&gt;Upload funny pictures, paste pictures or YouTube URL, accepting GIF/JPG/PNG (Max size: 3MB)&lt;/p&gt;
              &lt;label for="postTitle"&gt;&lt;?php _e('* Title of the image:', 'framework') ?&gt;&lt;/label&gt;
  
              &lt;input type="text" name="postTitle" id="postTitle" class="required" value="&lt;?php if ( isset( $_POST['postTitle'] ) ) echo $_POST['postTitle']; ?&gt;" /&gt;
          &lt;/fieldset&gt;
  
      &lt;div id="file-input" class="file-field"&gt;
      &lt;input type="file" name="thumbnail" id="thumbnail"&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>And this is my validation code :</p>
  
  <pre><code>// validation
  wp_register_script( 'validation', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js', array( 'jquery' ) );
  wp_enqueue_script( 'validation' );
  if ( isset( $_POST['submitted'] ) &amp;&amp; isset( $_POST['post_nonce_field'] ) &amp;&amp; wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) {
      if ( trim( $_POST['postTitle'] ) === '' ) {
          $postTitleError = 'Please enter a title.';
          $hasError = true;
      }
      $post_information = array(
          'post_title' =&gt; wp_strip_all_tags( $_POST['postTitle'] ),
          'post_content' =&gt; $_POST['postContent'],
          'post_type' =&gt; 'post',
          'post_status' =&gt; 'pending'
      );
  $new_post = wp_insert_post( $post_information );
  if (!function_exists('wp_generate_attachment_metadata')){
                  require_once(ABSPATH . "wp-admin" . '/includes/image.php');
                  require_once(ABSPATH . "wp-admin" . '/includes/file.php');
                  require_once(ABSPATH . "wp-admin" . '/includes/media.php');
              }
               if ($_FILES) {
                  foreach ($_FILES as $file =&gt; $array) {
                      if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
                          return "upload error : " . $_FILES[$file]['error'];
                      }
                      $attach_id = media_handle_upload( $file, $new_post );
                  }   
              }
              if ($attach_id &gt; 0){
                  //and if you want to set that image as Post  then use:
                  update_post_meta($new_post,'_thumbnail_id',$attach_id);
              }
  }
  </code></pre>
  
  <p>How can i accomplish this?</p>