Code Monkey home page Code Monkey logo

kartinki

Creating image thumbnails with simple configs like "200x200", "1280x720:fit,quality=75".

Latest Stable Version Build Status License

Code Climate Scrutinizer Code Quality SensioLabsInsight

Requirements

  • PHP 5.4+, 7.0, HHVM
  • GD extension enabled

Installing

  • Add "kartinki/kartinki": "~2.0.0" to composer.json.
  • Run composer install

Simple usage example

filename.jpg is 1600x1200.

<?php

$config = [
    'square' => '200x200',
    'normal' => '400x400:fit',
    'big'    => '1280x720:fit,quality=100',
];

$result = (new kartinki\Kartinki\Thumbnailer)->createThumbnails(
    '/path/to/image/filename.jpg',
    $config,
    '/output/dir' // optional
);

Thumbnailer will place 3 files to /output/dir:

1ceebb2cf4b0425a0ea1e1cb49810a07_square.jpg // 200x200
1ceebb2cf4b0425a0ea1e1cb49810a07_normal.jpg // 400x300
1ceebb2cf4b0425a0ea1e1cb49810a07_big.jpg    // 960x720

And $result will be instanse of kartinki\Kartinki\Result:

<?php
$result->getThumbnails();
// [
//     'square' => '1ceebb2cf4b0425a0ea1e1cb49810a07_square.jpg',
//     'normal' => '1ceebb2cf4b0425a0ea1e1cb49810a07_normal.jpg',
//     'big'    => '1ceebb2cf4b0425a0ea1e1cb49810a07_big.jpg'
// ]
 
$result->getUniqueId();
// '1ceebb2cf4b0425a0ea1e1cb49810a07'

$result->getExtension();
// 'jpg'

Versioning

From version 1.0.0 kartinki uses Semantic Versioning.

kartinki's Projects

kartinki icon kartinki

Creating image thumbnails with simple configs like "200x200", "1280x720:fit,quality=75".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.