<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Sets the image ticks-per-second</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagick.setimagescene.html">Imagick::setImageScene</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagick.setimagetype.html">Imagick::setImageType</a></div> <div class="up"><a href="class.imagick.html">Imagick</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="imagick.setimagetickspersecond" class="refentry"> <div class="refnamediv"> <h1 class="refname">Imagick::setImageTicksPerSecond</h1> <p class="verinfo">(PECL imagick 2.0.0)</p><p class="refpurpose"><span class="refname">Imagick::setImageTicksPerSecond</span> — <span class="dc-title">Sets the image ticks-per-second</span></p> </div> <div class="refsect1 description" id="refsect1-imagick.setimagetickspersecond-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>Imagick::setImageTicksPerSecond</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$ticks_per_second</code></span> )</div> <p class="para rdfs-comment"> Adjust the amount of time that a frame of an animated image is displayed for. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> 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 frame is displayed for to simulate the change in 'ticks per second'. </p> <p class="para"> For example, for an animated GIF where each frame is displayed for 20 ticks (1/5 of a second) when this method is called on each frame of that image with an argument of <em>50</em> the frames are adjusted to be displayed for 40 ticks (2/5 of a second) and the animation will play at half the original speed. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-imagick.setimagetickspersecond-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">ticks_per_second</code></em></span> <dd> <p class="para"> The duration for which an image should be displayed expressed in ticks per second. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-imagick.setimagetickspersecond-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success. </p> </div> <div class="refsect1 examples" id="refsect1-imagick.setimagetickspersecond-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3341"> <p><strong>Example #1 Modify animated Gif with <span class="function"><strong>Imagick::setImageTicksPerSecond()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// Modify an animated gif so the first half of the gif is played at half the<br />// speed it currently is, and the second half to be played at double the speed<br />// it currently is<br /><br /></span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= new </span><span style="color: #0000BB">Imagick</span><span style="color: #007700">(</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #DD0000">"Test.gif"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">coalesceImages</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$totalFrames </span><span style="color: #007700">= </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">getNumberImages</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$frameCount </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br />foreach (</span><span style="color: #0000BB">$imagick </span><span style="color: #007700">as </span><span style="color: #0000BB">$frame</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">setImageTicksPerSecond</span><span style="color: #007700">(</span><span style="color: #0000BB">50</span><span style="color: #007700">);<br /> <br /> if (</span><span style="color: #0000BB">$frameCount </span><span style="color: #007700">< (</span><span style="color: #0000BB">$totalFrames </span><span style="color: #007700">/ </span><span style="color: #0000BB">2</span><span style="color: #007700">)) {<br /> </span><span style="color: #FF8000">// Modify the frame to be displayed for twice as long as it currently is<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">setImageTicksPerSecond</span><span style="color: #007700">(</span><span style="color: #0000BB">50</span><span style="color: #007700">);<br /> } else {<br /> </span><span style="color: #FF8000">// Modify the frame to be displayed for half as long as it currently is<br /> </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">setImageTicksPerSecond</span><span style="color: #007700">(</span><span style="color: #0000BB">200</span><span style="color: #007700">);<br /> }<br /><br /> </span><span style="color: #0000BB">$frameCount</span><span style="color: #007700">++;<br />}<br /><br /></span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">deconstructImages</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-></span><span style="color: #0000BB">writeImages</span><span style="color: #007700">(</span><span style="color: #DD0000">"/path/to/save/output.gif"</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="imagick.setimagescene.html">Imagick::setImageScene</a></div> <div class="next" style="text-align: right; float: right;"><a href="imagick.setimagetype.html">Imagick::setImageType</a></div> <div class="up"><a href="class.imagick.html">Imagick</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>