trisnawan/image-resizer

Resizer, Thumbnailer, Cropper Image with PHP Imagick

Installs: 55

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/trisnawan/image-resizer

v1.1.0 2024-01-29 12:09 UTC

This package is auto-updated.

Last update: 2025-10-29 03:33:02 UTC


README

Change the maximum image size to get storage-efficient image files. Crop the image into a square to make it easier to create a profile photo.

Instalation

composer require trisnawan/image-resizer

Initialization

use Trisnawan\ImageResizer\ImageResizer;
// Image from user upload
$filePath = $_FILES["image"]["tmp_name"];

// Image from local storage
$filePath = "path/to/image_file.jpg";

$resizer = new ImageResizer($filePath);

Simple reduce image size

Use the maximum pixels and the image will be automatically reduced to the maximum size.

// Max Width in pixels
$maxWidth = 640;
$resizer->maxWidth($maxWidth);

Simple crop image

// Crop the image into a square from the center
$resizer->cropCenter();

// Crop the image into a square from the top
$resizer->cropTop();

Save to local storage

$saveFilePath = "path/to/image_new.jpg";
$resizer->writeImage($saveFilePath);

Show Blob image

// Show in blob
$resizer->getBlob();