Skip to content

Creating GIF animations - Considering migration from PHP Imagick #225

Answered by jcupitt
lemontango asked this question in Q&A
Discussion options

You must be logged in to vote

I made a tiny PHP example:

#!/usr/bin/env php
<?php

require dirname(__DIR__) . '/vendor/autoload.php';
use Jcupitt\Vips;

#Vips\Config::setLogger(new Vips\DebugLogger());

if (count($argv) != 4) {
    echo("usage: ./animate-image.php input-image output-image 'text string'\n");
    exit(1);
}

$image = Vips\Image::newFromFile($argv[1]);
$text = Vips\Image::text($argv[3], ["dpi" => 300, "rgba" => true]);
$animation = NULL;
$delay = [];

for ($x = 0; $x < $image->width + $text->width; $x += 10)
{
    // append the frame to the image vertically ... we make a very tall, thin
    // strip of frames to save
    $frame = $image->composite2($text, "over", [
        "x" => $x - $text->width,
        

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lemontango
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants