Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Basic image conversion for Kirby 2: RGB Profile and resize for optimized web display.

Notifications You must be signed in to change notification settings

amteich/kirby-imageconverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Kirby ImageConverter

This plugin for Kirby 2 allows you to convert your images to rgb and resize them down for web use.

It is based on the Thumb class of the Kirby Toolkit.

License: GNU GPL v3.0

Requirements

  • Imagemagick
  • php exec must be allowed

This plugin doesn't work with GDLib.

Installation

Use one of the alternatives below.

1. Kirby CLI

If you are using the Kirby CLI you can install this plugin by running the following commands in your shell:

$ cd path/to/kirby
$ kirby plugin:install madergrafisch/kirby-imageconverter

2. Clone or download

  1. Clone or download this repository.
  2. Unzip the archive if needed and rename the folder to kirby-imageconverter.

Make sure that the plugin folder structure looks like this:

site/plugins/kirby-imageconverter/

Usage

Use kirby 2 panel upload hook to process images on file upload.

kirby()->hook('panel.file.upload', function($file) {

  if ($file->type() == 'image') {
		mgf\ImageConverter::convert($file, array(
      'width' => 1024,
      'height' => 1024,
      'tosRGB' => true,
    ));
  }

});

Examples

Create a new ImageConverter Object by passing a Media Object and some params.

mgf\ImageConverter::convert($image);

This uses the default options, like below.

mgf\ImageConverter::convert($image, array(
  'width' => 1024,
  'height' => 1024,
  'tosRGB' => true,
));

This converts your image to a maximum size of 1024x1024 px and converts its colorspace to sRGB.

mgf\ImageConverter::convert($image, array(
  'destination' => '{name}_resized.{extension}',
));

This creates a new image in the same destination, as the original image and adds the suffix '_resized' to the filename.

Options

The class offers some options, most of them by the Kirby Thumb Class.

Default Options

'destination'   => '{name}.{extension}'
'url'        => null
'root'       => null
'quality'    => 100
'blur'       => false
'blurpx'     => 10
'width'      => null
'height'     => null
'upscale'    => false
'crop'       => false
'grayscale'  => false
'tosRGB'     => false
'autoOrient' => false
'interlace'  => false

Credits

About

Basic image conversion for Kirby 2: RGB Profile and resize for optimized web display.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages