Download the PHP package migears/image without Composer

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

migears/image

Version

A minimalist image processing toolkit based on PHP 8.1+ and the GD extension.

Background: miGears is the open-source successor of TinyGears, a self-developed PHP framework. It was renamed and open-sourced recently because the name TinyGears is already taken in the open-source community.

Features

Boundaries

In scope

Not in scope (by design)

Requirements

Installation

Quick Start

Rotate & Flip

Output Directly to Browser

Practical: User Upload Thumbnail Generator

API Overview

Construction

Information

Method Description
info(): ImageInfo Get image information (width, height, type, mime, extension)

Resizing

Method Description
resize(int $width, int $height): static Resize to specified dimensions (may distort)
resizeToWidth(int $width): static Proportional resize (by width)
resizeToHeight(int $height): static Proportional resize (by height)
resizeToMax(int $maxSize): static Proportional resize by the longest side

Cropping

Method Description
crop(int $w, int $h, int $x = 0, int $y = 0): static Crop at specified position
cropCenter(int $width, int $height): static Center crop
thumbnail(int $width, int $height): static Thumbnail (resize + center crop)

Rotation & Flipping

Method Description
rotate(int $degrees, int $bgColor = 0): static Rotate image
flipHorizontal(): static Flip horizontally (left-right mirror)
flipVertical(): static Flip vertically (top-bottom mirror)
flipBoth(): static Flip both directions

Watermarks

Method Description
imageWatermark(string\|ImageInterface $wm, int $x, int $y, int $opacity): static Image watermark ($opacity 0-100)
textWatermark(string $text, string $font, int $size, int $x, int $y, int $opacity, int $color): static Text watermark ($opacity 0-100)

Saving & Output

Method Description
save(string $path, ?ImageType $type = null, int $quality = 90): bool Save to file ($quality 0-100); returns false if the write fails
output(?ImageType $type = null, int $quality = 90): string Output as binary string ($quality 0-100)

Other

Method Description
resource(): \GdImage Get raw GD image object
destroy(): void Releases the image (no-op on PHP 8.0+, where it is freed when released)

Core Classes

ImageInfo (readonly value object)

ImageType Enum

Exceptions

All failures throw MiGears\Image\Exception\ImageException, including out-of-range parameters ($quality and $opacity must be between 0 and 100) and a declared type that contradicts the detected one. The one exception is save(): when the file cannot be written it returns false instead of throwing, so callers must check the return value.

Testing

License

MIT


migears/image

Version

极简图像处理工具包,基于 PHP 8.1+ 和 GD 扩展。

特性

边界

范围内

范围外(刻意不做)

要求

安装

快速开始

旋转 & 翻转

直接输出到浏览器

实战:用户上传缩略图生成器

API 概览

构造

信息

方法 说明
info(): ImageInfo 获取图片信息(宽、高、类型、mime、扩展名)

缩放

方法 说明
resize(int $width, int $height): static 缩放到指定尺寸(可能变形)
resizeToWidth(int $width): static 等比例缩放(按宽度)
resizeToHeight(int $height): static 等比例缩放(按高度)
resizeToMax(int $maxSize): static 按最大边等比例缩放

裁剪

方法 说明
crop(int $w, int $h, int $x = 0, int $y = 0): static 指定位置裁剪
cropCenter(int $width, int $height): static 居中裁剪
thumbnail(int $width, int $height): static 缩略图(缩放+居中裁剪)

旋转 & 翻转

方法 说明
rotate(int $degrees, int $bgColor = 0): static 旋转图片
flipHorizontal(): static 水平翻转(左右镜像)
flipVertical(): static 垂直翻转(上下镜像)
flipBoth(): static 双向翻转

水印

方法 说明
imageWatermark(string\|ImageInterface $wm, int $x, int $y, int $opacity): static 图片水印($opacity 0-100)
textWatermark(string $text, string $font, int $size, int $x, int $y, int $opacity, int $color): static 文字水印($opacity 0-100)

保存 & 输出

方法 说明
save(string $path, ?ImageType $type = null, int $quality = 90): bool 保存到文件($quality 0-100);写入失败时返回 false
output(?ImageType $type = null, int $quality = 90): string 输出二进制字符串($quality 0-100)

其他

方法 说明
resource(): \GdImage 获取原始 GD 图像对象
destroy(): void 释放图像(PHP 8.0+ 下为空操作,对象释放时自动回收)

核心类

ImageInfo(readonly 值对象)

ImageType 枚举

异常

所有失败均抛出 MiGears\Image\Exception\ImageException,包括参数越界($quality 与 $opacity 必须在 0-100 之间)以及声明类型与检测类型不一致。唯一例外是 save():文件无法写入时它返回 false 而不抛异常,调用方必须检查返回值。

测试

License

MIT


All versions of image with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 migears/image contains the following files

Loading the files please wait ...