Download the PHP package justsmiletoo/laravel-file-compressor without Composer

On this page you can find all versions of the php package justsmiletoo/laravel-file-compressor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-file-compressor

Laravel File Compressor

CI Latest Version on Packagist Total Downloads License

Automatically compress images, PDFs and videos on upload in Laravel. Auto-detects the MIME type and applies the right compressor — zero config needed.

Requirements

Installation

The service provider is auto-discovered. To publish the config file:

System binaries (optional)

For PDF compression, install Ghostscript:

For video compression, install FFmpeg:

Usage

Auto-detect and compress

The compress() method detects the file type and delegates to the right compressor:

Type-specific methods

Skip MIME detection and call a compressor directly:

Presets

Use named presets for common image use cases:

Define your own presets in the config:

Resize modes

Per-call options

Override config values for a single call:

CompressionResult

Every compression call returns a CompressionResult DTO:

Integration example

Typical usage in a file upload service:

Check support

Configuration

Key Default Description
enabled true Global toggle. Set to false to skip all compression.
temp_dir sys_get_temp_dir() Temporary directory for processing.
Image
image.driver gd Image driver: gd or imagick.
image.quality 80 JPEG/WebP quality (1-100).
image.max_width 1920 Max width in pixels. Aspect ratio preserved.
image.max_height 1080 Max height in pixels. Aspect ratio preserved.
image.mode scale Resize mode: scale (proportional) or cover (crop to fill).
image.convert_to null Convert format: null (keep original), webp, jpg, png.
image.presets [...] Named presets with per-preset options. See Presets.
PDF
pdf.binary gs Path to the Ghostscript binary.
pdf.quality ebook Preset: screen (72dpi), ebook (150dpi), printer (300dpi), prepress.
pdf.timeout 60 Process timeout in seconds.
Video
video.binary ffmpeg Path to the FFmpeg binary.
video.codec libx264 Video codec.
video.crf 28 Constant Rate Factor (0-51). Lower = better quality, larger file.
video.preset medium Encoding speed preset. Slower = better compression.
video.max_width 1280 Max width in pixels (never upscales).
video.audio_bitrate 128k Audio bitrate.
video.timeout 300 Process timeout in seconds.

All values can be overridden via environment variables. See config/file-compressor.php for the full list.

Handling unsupported files

If a file type is not supported, compress() throws UnsupportedFileTypeException. You can check support beforehand:

Or catch the exception:

Temp file cleanup

Compressed files are written to the configured temp_dir. After storing the compressed file to your disk, the temp file can be safely deleted. The OS will also clean up temp files periodically.

Testing

Place test fixtures (sample.jpg, sample.pdf, sample.mp4) in tests/Fixtures/ to enable all tests.

License

MIT. See LICENSE.


All versions of laravel-file-compressor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/contracts Version ^11.0|^12.0|^13.0
intervention/image Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package justsmiletoo/laravel-file-compressor contains the following files

Loading the files please wait ...