Download the PHP package tihloh/prefab-image without Composer

On this page you can find all versions of the php package tihloh/prefab-image. 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 prefab-image

Prefab Image

Prefab Image provides fast, framework-independent image inspection, resizing, cropping, conversion and browser delivery for PHP applications.

Process once. Store optimized variants. Serve static files directly whenever possible.

The package uses PHP GD directly and keeps the hot path small: no ORM, service container, reflection or automatic database work.

Requirements

Installation

When published:

Quick start

resize(1200) preserves the aspect ratio and does not upscale by default.

Resize inside a box

The image fits inside 1200x800 while preserving its aspect ratio.

Cover / thumbnail

Shortcut:

cover() scales and center-crops to fill the requested dimensions. It does not upscale unless explicitly requested.

Crop, rotate and flip

Flip directions:

Auto orientation

When ext-exif is available, JPEG EXIF orientation is applied. Without EXIF support the call is a no-op.

Formats and quality

Supported formats depend on the installed GD build:

Prefab checks encoder support before using optional formats such as WebP and AVIF.

Save, encode or display

Save to a file:

Return encoded binary data:

Display the PHP response directly as an image:

Then the PHP endpoint can be used directly:

display() emits the image body and the correct Content-Type. It does not call exit, so request termination remains under application control.

Browser cache headers

For versioned image URLs:

Cheap image inspection

When only dimensions or MIME information are needed, do not decode the full bitmap:

This is useful for generating correct HTML dimensions:

Cached derivatives

For frequently requested thumbnails and resized images, avoid decoding and processing the source on every request.

If the target exists and is at least as new as the source, generate() returns immediately before decoding the source image.

This is the preferred pattern for dynamic image endpoints that also maintain a disk cache.

Fast delivery strategy

For public images, the fastest normal path is:

Avoid this for every page load when the result can be cached:

Use PHP processing when generating a derivative, serving protected images or producing a one-off response. Reuse the generated static derivative afterward whenever possible.

Responsive variants

A practical upload workflow can generate several widths once:

Then let the browser choose the smallest useful file:

Performance design

The processing object is deliberately mutable. Fluent calls such as quality() and format() do not clone the decoded bitmap. Transformations replace the current GD image resource and release the previous one as soon as it is no longer needed.

Key rules:

API quick reference

API Purpose
Image::open() Decode an image file
Image::fromString() Decode image bytes
Image::inspect() Read dimensions/MIME without full processing
Image::generate() Generate a derivative only when stale/missing
resize() Fit while preserving aspect ratio
cover() / thumbnail() Fill and center-crop
crop() Crop a specific rectangle
rotate() Rotate image
flip() Flip horizontally/vertically
autoOrient() Apply JPEG EXIF orientation when available
format() Choose output format
quality() Choose output quality
save() Atomically save to disk
encode() Return encoded bytes
display() Emit image HTTP response
width() / height() / ratio() Read current dimensions
mime() Read current output MIME

Scope

Prefab Image stays focused on image processing and delivery. It does not attempt to become a graphics editor.

Out of scope for the small core package:

Those capabilities can be separate packages or adapters when an application needs them.


All versions of prefab-image with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-gd Version *
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 tihloh/prefab-image contains the following files

Loading the files please wait ...