2017 © Pedro Peláez
 

library phpresizegif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

image

grandt/phpresizegif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  • Thursday, August 13, 2015
  • by Grandt
  • Repository
  • 2 Watchers
  • 9 Stars
  • 36,374 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

Resize animated Gif files

This package aims to implement a proper resizing of gif files encompassing the GIF89a specification., (*1)

Introduction

Most, if not all other publicly available gif resize packages fails with optimized gif files, those where only parts of the file are updated in subsequent frames. See these as a background image, with sprites moving about. The resulting gif will retain its aspect ratio., (*2)

The package is a bit pedantic in its approach. It was made as much for me to learn what Gifs were and how they work, as it was to solve specific problem., (*3)

Usage

The package needs to write to a file, the reasons for not just return a string is twofold. One being memory usage, the other is that you really don't want to be dynamically resizing often used gif files every time they are used., (*4)

Import

Add this requirement to your composer.json file:, (*5)

    "grandt/phpresizegif": ">=1.0.3"

Composer

If you already have Composer installed, skip this part., (*6)

Packagist, the main composer repository has a neat and very short guide., (*7)

Or you can look at the guide at the Composer site., (*8)

The easiest for first time users, is to have the composer installed in the same directory as your composer.json file, though there are better options., (*9)

Run this from the command line:, (*10)

php -r "readfile('https://getcomposer.org/installer');" | php

This will check your PHP installation, and download the composer.phar, which is the composer binary. This file is not needed on the server though., (*11)

Once composer is installed you can create the composer.json file to import this package., (*12)

{
    "require": {
        "grandt/phpresizegif": ">=1.0.3"
    }
}

Followed by telling Composer to install the dependencies., (*13)

php composer.phar install

this will download and place all dependencies defined in your composer.json file in the vendor directory., (*14)

Finally, you include the autoload.php file in the new vendor directory., (*15)

<?php
    require 'vendor/autoload.php';
    .
    .
    .

Initialization

include "../vendor/autoload.php";
use grandt\ResizeGif\ResizeGif;

$srcFile = "[path to original gif file]";
$dstFile = "[path to resized file]";

ResizeGif::ResizeToWidth($srcFile, $dstFile, 100);

To make a 100 pixel wide thumbnail

ResizeGif::ResizeToWidth($srcFile, $dstFile, 100);

To make a 100 pixel high thumbnail

ResizeGif::ResizeToHeight($srcFile, $dstFile, 100);

To double the size of the gif.

ResizeGif::ResizeByRatio($srcFile, $dstFile, 2.0);

To half the size of the gif.

ResizeGif::ResizeByRatio($srcFile, $dstFile, 0.5);

The Versions

13/08 2015

dev-master

9999999-dev https://github.com/Grandt/PHPResizeGif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  Sources   Download

LGPL-2.1

The Requires

 

gif resize animated gif gif89a

10/05 2015

1.0.3

1.0.3.0 https://github.com/Grandt/PHPResizeGif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  Sources   Download

LGPL-2.1

The Requires

 

gif resize animated gif gif89a

01/05 2015

1.0.2

1.0.2.0 https://github.com/Grandt/PHPResizeGif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  Sources   Download

LGPL-2.1

The Requires

 

gif resize animated gif gif89a

29/04 2015

1.0.1

1.0.1.0 https://github.com/Grandt/PHPResizeGif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  Sources   Download

LGPL-2.1

The Requires

 

gif resize animated gif gif89a

28/04 2015

1.0.0

1.0.0.0 https://github.com/Grandt/PHPResizeGif

GIF89a compliant Gif resizer, including transparency and optimized gifs with sub sized elements.

  Sources   Download

LGPL-2.1

The Requires

 

gif resize animated gif gif89a