Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6219675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:49:30+00:00 2026-05-24T07:49:30+00:00

I am trying to uncompress a binary file and then uncompress it to test

  • 0

I am trying to uncompress a binary file and then uncompress it to test whether the compresssion is working.
However the ‘uncompressed’ file has the same data as the ‘compressed’ file. As though the uncompression never happened. I have listed code below.
thanks in advance:

//compressing  
//read file  
$filename = 'tocompress/tocompress'.$number_input.'.bin';  
$contents=fread($fp,filesize($filename));  
fclose($fp);  
//compress file  
$compressing = gzcompress($contents , '0');  
//write to file  
$fp = fopen('compressed/compressed'.$number_input.'.bin', 'wb');  
 fwrite($fp, $compressing);  
 fclose($fp);  

//uncompressing  
//read file  
$uncompfilename='compressed/compressed'.$number_input.'.bin';  
$fp=fopen($uncompfilename,'rb');  
$uncompresscontents=fread($fp,filesize($uncompfilename));  
fclose($fp);  
//uncompress file  
$uncompressing = gzuncompress($uncompresscontents);  
//write to file  
$fp = fopen('uncompressed/uncompressed'.$number_input.'.bin', 'wb');  
 fwrite($fp, $uncompresscontents);  
fclose($fp);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:49:30+00:00Added an answer on May 24, 2026 at 7:49 am

    gzcompress takes an optional second argument which sets compression level, from 0-9. You’re setting it to 0 (no compression) and you should be using an int, not a string:

    You have gzcompress($contents, '0');

    You want gzcompress($contents, 9);

    From php.net/gzcompress:

    The level of compression. Can be given as 0 for no compression up to 9
    for maximum compression.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load a PNG file, get the uncompressed RGBA bytes, then
I am trying to uncompress some data created in VB6 using the zlib API.
I'm trying to uncompress a GZIPed HTTP Response by using GZIPInputStream . However I
I'm trying to use PSEXEC to uncompress a self extracting file (a console exe
Getting system.entrypointnotfoundexception: loadlibrary While trying to use SevenZipLib.dll to uncompress the .7z file containing
I am trying to convert compressed swf files to uncompressed swf files using the
I'm trying to convert a bitmap image into an uncompressed tif file for use
In my application I save voxel-data (compressed byte array) and trying to load it
I've been trying determine the uncompressed size of a compressed database dump. I've been
I am trying to read a bzip2-compressed CSV file in Python 3.2. For an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.