title: tar.gz compress didn't work for GIF file
body: <p>I'm trying to make a program to compress file to .tar.gz:</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.io.*;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import java.util.zip.GZIPOutputStream;
  import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
  import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
  
  public class Compress {
  
      public static void main(String[] args) {
          BufferedInputStream input = null;
          try {
              input = new BufferedInputStream(new FileInputStream(new File("input_filename.filetype")));
              TarArchiveOutputStream out = null;
              try {
                  out = new TarArchiveOutputStream(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream("output_filename.tar.gz"))));
                  out.putArchiveEntry(new TarArchiveEntry(new File("input_filename.filetype")));
  
                  int count;
                  byte data[] = new byte[input.available()];
                  while ((count = input.read(data)) != -1) {
                      out.write(data, 0, count);
                  }
  
                  input.close();
              } catch (IOException ex) {
                  Logger.getLogger(Compress.class.getName()).log(Level.SEVERE, null, ex);
              } finally {
                  if (out != null) {
                      try {
                          out.closeArchiveEntry();
                          out.close();
                      } catch (IOException ex) {
                          Logger.getLogger(Compress.class.getName()).log(Level.SEVERE, null, ex);
                      }
                  }
              }
          } catch (FileNotFoundException ex) {
              Logger.getLogger(Compress.class.getName()).log(Level.SEVERE, null, ex);
          } finally {
              try {
                  input.close();
              } catch (IOException ex) {
                  Logger.getLogger(Compress.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
      }
  }
  </code></pre>
  
  <p>I'm using <a href="http://commons.apache.org/compress/download_compress.cgi" rel="nofollow noreferrer">Apache Commons Compression</a> as the library.</p>
  
  <p>I test with 2 conditions:</p>
  
  <ol>
  <li>Compress GIF File</li>
  <li>Compress PDF File</li>
  </ol>
  
  <p>And I compare compress using <a href="http://peazip.sourceforge.net/" rel="nofollow noreferrer">PeaZip</a>, here is the result:</p>
  
  <ol>
  <li><img src="https://i.stack.imgur.com/s07ql.png" alt="Compare GIF, From Left to Right -&gt; Code Above, PeaZip, File Input"></li>
  <li><img src="https://i.stack.imgur.com/pQhku.png" alt="Compare PDF, From Left to Right -&gt; Code Above, PeaZip, File Input"></li>
  </ol>
  
  <p><strong>If the input file is GIF the size of the compress file increase, same if we using <a href="http://peazip.sourceforge.net/" rel="nofollow noreferrer">PeaZip</a>. But for the other file it works for the compression process.</strong></p>
  
  <p>Can anyone explain what happen with this? Is there are something wrong with my code?</p>
  
  <p>Thank you for your help...</p>