Download the PHP package harmim/images without Composer

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

A tool for working with images

Build Coding Style Static Analysis Tests Coverage Monthly Downloads Total Downloads Version PHP Version Require License

About

A tool for working with images. It can be used as an extension of the Nette Framework.

There is Image storage for storing images easily and/or deleting them from the storage. There are also several ways how to resize and/or process images. Then, you can get a stored image path directly, or you can use prepared Latte macros to generate HTML tags. See Usage.

Requires the PHP version 8.2 or newer and PHP extensions fileinfo, gd, and intl.

Installation

Download the latest release or use Composer:

Usage

For working with images, we need \Harmim\Images\ImageStorage:

Without Nette

In $customConfig, you can specify a custom configuration. See Configuration.

With Nette

You can enable and customise the extension using your NEON config:

In the images section, you can specify a custom configuration. See Configuration.

\Harmim\Images\ImageStorage is now registrated in the DI container. You can get it directly from the container:

Of course, you can inject \Harmim\Images\ImageStorage through a constructor, inject method, inject annotation, or any other way.

If you want to use \Harmim\Images\ImageStorage in a presenter or control where inject methods are called, you can use trait \Harmim\Images\TImageStorage. In your presenters, controls, and theire templates, there will be variable $imageStorage.

The extension installs images macros to Latte. See Macros.

Storing Images

You can store an image using method \Harmim\Images\ImageStorage::saveImage(string $name, string $path): string or \Harmim\Images\ImageStorage::saveUpload(\Nette\Http\FileUpload $file): string. An original image will be stored; then, it will be compresed.

Both methods return a stored image file name. You can use this file name to delete, resize, or retrieve the image.

Images are stored with a unique file name and location.

Deleting Images

Using method \Harmim\Images\ImageStorage::deleteImage(string $fileName, array $excludedTypes = []): void, you can delete an image by $fileName which should be a file name returned by \Harmim\Images\ImageStorage::saveImage or \Harmim\Images\ImageStorage::saveUpload.

If you pass $excludedTypes, only other types will be deleted; otherwise, all types, the original image, and the compressed image will be deleted.

Getting Stored Images' Paths

You can get a stored image path using method \Harmim\Images\ImageStorage::getImageLink(string $fileName, ?string $type = null, array $options = []): ?string or Macros. You can pass a specific type defined in an inital configuration, or you can pass specific options. See Configuration. $fileName should be a file name returned by \Harmim\Images\ImageStorage::saveImage or \Harmim\Images\ImageStorage::saveUpload.

If you try to get an image of a size or a type for a first time, this image is not yet created, so it will be created now. Next time, you will get a resized image.

If the image does not exist, a placeholder will be returned.

In case you need to get an original/compressed image, in the configuration, you can use orig/compressed, respectively. For example, ['orig' => true]. It is also possible to use these options in macros.

Macros

img

Renders the img tag:

or tags for lazy loading with the lazy option:

Examples:

n:img

Renders the src attribute. It can be used, e.g., in the img element.

Examples:

imgLink

Returns a relative path (from the resource root directory) to a given image.

Examples:

Configuration

Transform-Options

Option Description
\Harmim\Images\Resize::ShrinkOnly Only shrinking (prevents a small image from being stretched).
\Harmim\Images\Resize::Stretch Do not keep the aspect ratio.
\Harmim\Images\Resize::OrSmaller The resulting dimensions will be smaller or equal to the required dimensions.
\Harmim\Images\Resize::OrBigger Fills (and possibly exceeds in one dimension) the target area.
\Harmim\Images\Resize::Cover Fills the target area and cuts off what goes beyond.
\Harmim\Images\Resize::Exact Placees a not stretched image to the exact blank area.

License

This tool is licensed under the MIT license.


Author: Dominik Harmim [[email protected]](mailto:[email protected])


All versions of images with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-fileinfo Version *
ext-gd Version *
ext-intl Version *
latte/latte Version ^3.0
nette/di Version ^3.1
nette/http Version ^3.2
nette/utils Version ^4.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 harmim/images contains the following files

Loading the files please wait ....