PHPackages                             mitmelon/compress - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. mitmelon/compress

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mitmelon/compress
=================

Advanced file compresser which reduces and encrypt large files to smaller chunks by saving them as binary for later use.

3.0.0(2y ago)184.2k7MITPHPPHP &gt;=5.6.0

Since Mar 12Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/mitmelon/Compress)[ Packagist](https://packagist.org/packages/mitmelon/compress)[ Docs](https://manomite.net)[ RSS](/packages/mitmelon-compress/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

[![File Compress](https://private-user-images.githubusercontent.com/55149512/280674632-d566ece6-41c3-4d25-9aae-d9bca05570f6.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ5MDA3NzIsIm5iZiI6MTc3NDkwMDQ3MiwicGF0aCI6Ii81NTE0OTUxMi8yODA2NzQ2MzItZDU2NmVjZTYtNDFjMy00ZDI1LTlhYWUtZDliY2EwNTU3MGY2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAzMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMzMwVDE5NTQzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlMGI2ZGY5MDQxY2NkZjIwMzNiMmY4MmM1NzFjYzcxNzExMjE2ODM3ZTdiYjdlZjI2YTNkN2U5MmY5YmQ4NzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.jnELdYqRmIuOd_q1A1oN0xtmfULjAtzY_IK3NNg1T5k)](#)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#)

Compress
========

[](#compress)

[![FOSSA Status](https://camo.githubusercontent.com/86038f11d79ed5b7809768b95a43669fe1fd8be7b6316b619f6eea716098f951/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532466d69746d656c6f6e253246436f6d70726573732e7376673f747970653d736869656c64)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmitmelon%2FCompress?ref=badge_shield) [![Total Downloads](https://camo.githubusercontent.com/e89012b214a477d422d6d19cfc2d53f11e35c820fc5c45c950430830d782ccf1/687474703a2f2f706f7365722e707567782e6f72672f6d69746d656c6f6e2f636f6d70726573732f646f776e6c6f616473)](https://packagist.org/packages/mitmelon/compress) [![License](https://camo.githubusercontent.com/e80b5242686ebf3b6b157157f40eb42960ad98bce7058eb94d753c12210f104a/687474703a2f2f706f7365722e707567782e6f72672f6d69746d656c6f6e2f636f6d70726573732f6c6963656e7365)](https://packagist.org/packages/mitmelon/compress) [![PHP Version Require](https://camo.githubusercontent.com/eac7e27842ff35249d2d8c5ec4e258e7dbe8948991c7a0f51459a8ae126bbdc9/687474703a2f2f706f7365722e707567782e6f72672f6d69746d656c6f6e2f636f6d70726573732f726571756972652f706870)](https://packagist.org/packages/mitmelon/compress)

Advanced file compresser which reduces and encrypts large files to smaller chunks by saving them as binary for later use. Many applications supports file uploads which consumes large memory sizes on their systems. This library has been designed to reduce both zip, rar, images, pdf, words sizes or any kinds of files or documents into smaller size.

Install:
--------

[](#install)

Use composer to install

```
composer require mitmelon/compress
```

Usage :
-------

[](#usage-)

```
require_once __DIR__."/vendor/autoload.php";

// Initialize library class
$compress = new Compress\Compress();
```

Compress File Only
------------------

[](#compress-file-only)

```
/**
 * @param String $filePath
 * File location to be compressed
 * @param String $storePath
 * Path to output compressed binary file to
 * @param Mixed $options ["removeMeta" => false, "encrypt" => false, "key" => "password", "scanFile" => ["token" => $token, "service" => $service, "csp" => $csp, "region" => $region]]
 * Options to remove meta, encrypt file and scan content for reputations
 */
$compress::compressFile($filePath, $storePath, $options = []);

//Compress Image file
$compress::compressFile(__DIR__.'/image.png', __DIR__.'/image.txt');

// Compress PDF
$compress::compressFile(__DIR__.'/file.pdf', __DIR__.'/file.txt');
```

Scan File and Compress
----------------------

[](#scan-file-and-compress)

Scan content to get informations such as file's disposition, ranging from malicious (malware, ransomware, trojan horses, spyware, adware) to known good content (operating system files, known third-party software packages) using Pangea's File Intel Service.

To use the Pangea's File Intel Service [create an account](https://pangea.cloud) and plug your credentials into the options below. Account creation is free.

```
$options = array("scanFile" => array("token" => "{File_Intel_API_Token}", "service" => 'file-intel', "csp" => 'aws', "region" => 'us'));
$compress::compressFile(__DIR__.'/file.pdf', __DIR__.'/file.txt', $options);
```

Decompress File
---------------

[](#decompress-file)

```
/**
 * UnCompress Image file [Get original file back from stored binary]
 * @param String $storePath
 * Path containing binary file which was compressed
 * @param String $fileOutputPath
 * Path to output original file to
 * @param String $encrypt_key
 * If your file was encrypted then provide the key for decryption as third argument
 */
$compress::uncompressFile($storePath, $fileOutputPath, $encrypt_key = null);

//Uncompress Image
$compress::uncompressFile(__DIR__.'/image.txt', __DIR__.'/image.png');

// Uncompress PDF
$compress::uncompressFile( __DIR__.'/file.txt', __DIR__.'/file.pdf')
```

Other Public Variables To Change
--------------------------------

[](#other-public-variables-to-change)

```
    /**
     * Encryption block chunk size
     *
     * @param Int $block
     */
    public int $block = 1024;
    /**
     * Compression and Uncompression chunk size
     *
     * @param Int $compress_chunk_size
     */
    public int $compress_chunk_size = 100 * 1024 * 1024; // 100 MB
    /**
     * Encryption cipher
     *
     * @default aes-256-cbc
     */
    public string $cipher = 'aes-256-cbc';
```

Changelog
=========

[](#changelog)

All notable changes to this project will be documented here.

\[3.0.0\] - 2023-06-11
----------------------

[](#300---2023-06-11)

- 🌟 Added Pangea's File Intel Service to get file reputations and only allow secure content for compressing
- 🌟 Updated compressor, uncompressor and file handlers to handle large file without consuming huge memory
- 🌟 Fixed Bugs and updated the documentation page

\[2.0.0\] - 2022-03-12
----------------------

[](#200---2022-03-12)

- 🌟 Added AES 256 CBC Mode encryption

Future Update
=============

[](#future-update)

- Store files on centralize and decentralize cloud providers

Support
=======

[](#support)

If you love my project and wish to assist me to keep working on this project. Please follow this link [](https://flutterwave.com/donate/oq61dyrjk9xh) to donate.

License
=======

[](#license)

Released under the MIT license.

[![FOSSA Status](https://camo.githubusercontent.com/39b28b27bb8a5b22e222928e597b98fae4bfbaa96e81523c72cf3f9efc9644e2/68747470733a2f2f6170702e666f7373612e636f6d2f6170692f70726f6a656374732f6769742532426769746875622e636f6d2532466d69746d656c6f6e253246436f6d70726573732e7376673f747970653d6c61726765)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmitmelon%2FCompress?ref=badge_large)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance54

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~603 days

Total

2

Last Release

924d ago

Major Versions

v2.0.0 → 3.0.02023-11-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f05a05a056e93b9cd6513702b8c1af6f6ae71a9c8e288230ec1c10c6ffa3719?d=identicon)[mitmelon](/maintainers/mitmelon)

---

Top Contributors

[![mitmelon](https://avatars.githubusercontent.com/u/55149512?v=4)](https://github.com/mitmelon "mitmelon (28 commits)")[![ruthbri](https://avatars.githubusercontent.com/u/52461960?v=4)](https://github.com/ruthbri "ruthbri (3 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")

---

Tags

encryptionarchivezipfilecompresscompress filesadvance file compressersave memoryfile compresserencrypt fileremove meta

### Embed Badge

![Health badge](/badges/mitmelon-compress/health.svg)

```
[![Health](https://phpackages.com/badges/mitmelon-compress/health.svg)](https://phpackages.com/packages/mitmelon-compress)
```

###  Alternatives

[nelexa/zip

PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.

4967.4M112](/packages/nelexa-zip)[wapmorgan/unified-archive

UnifiedArchive - an archive manager with unified interface of working with all popular archive formats (zip/7z/rar/gz/bz2/xz/cab/tar/tar.gz/tar.bz2/tar.x/tar.Z/...) for PHP with ability for listing, reading, extracting and creation + built-in console archive manager.

2791.6M7](/packages/wapmorgan-unified-archive)[league/flysystem-ziparchive

ZIP filesystem adapter for Flysystem.

1039.3M58](/packages/league-flysystem-ziparchive)[splitbrain/php-archive

Pure-PHP implementation to read and write TAR and ZIP archives

1061.4M20](/packages/splitbrain-php-archive)[phpzip/phpzip

Package to create and stream archives of compressed files in ZIP format with PHP 5.3+

124840.7k9](/packages/phpzip-phpzip)[raulfraile/distill

Smart compressed files extractor

228190.4k9](/packages/raulfraile-distill)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
