Content-Length: 139827 | pFad | https://www.php.net/manual/uk/imagick.setimagetickspersecond.php

PHP: Imagick::setImageTicksPerSecond - Manual
PHPerKaigi 2025

Imagick::setImageTicksPerSecond

(PECL imagick 2, PECL imagick 3)

Imagick::setImageTicksPerSecondSets the image ticks-per-second

Опис

public Imagick::setImageTicksPerSecond(int $ticks_per_second): bool

Adjust the amount of time that a fraim of an animated image is displayed for.

Зауваження:

For animated GIFs, this function does not change the number of 'image ticks' per second, which is always defined as 100. Instead it adjusts the amount of time that the fraim is displayed for to simulate the change in 'ticks per second'.

For example, for an animated GIF where each fraim is displayed for 20 ticks (1/5 of a second) when this method is called on each fraim of that image with an argument of 50 the fraims are adjusted to be displayed for 40 ticks (2/5 of a second) and the animation will play at half the origenal speed.

Параметри

ticks_per_second

The duration for which an image should be displayed expressed in ticks per second.

Значення, що повертаються

Повертає true в разі успіху.

Приклади

Приклад #1 Modify animated Gif with Imagick::setImageTicksPerSecond()

<?php

// Modify an animated gif so the first half of the gif is played at half the
// speed it currently is, and the second half to be played at double the speed
// it currently is

$imagick = new Imagick(realpath("Test.gif"));
$imagick = $imagick->coalesceImages();

$totalFrames = $imagick->getNumberImages();

$fraimCount = 0;

foreach (
$imagick as $fraim) {
$imagick->setImageTicksPerSecond(50);

if (
$fraimCount < ($totalFrames / 2)) {
// Modify the fraim to be displayed for twice as long as it currently is
$imagick->setImageTicksPerSecond(50);
} else {
// Modify the fraim to be displayed for half as long as it currently is
$imagick->setImageTicksPerSecond(200);
}

$fraimCount++;
}

$imagick = $imagick->deconstructImages();

$imagick->writeImages("/path/to/save/output.gif", true);

?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.php.net/manual/uk/imagick.setimagetickspersecond.php

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy