Blog

  • gif2frames.exe: Extract frames from an animated GIF

    I built a Windows 32 bit command line executable, gif2frames.exe. (Go to download)

    This tool will take an animated GIF image file and save a separate static image for each frame in PNG, BMP or JPG format.

    The reason GIFs are useful is because the files can be optimized to reduce the size on disk. If a frame is visible for 1 or 10 seconds, a single copy of the frame may be stored inside the image file and a frame delay can help the player coordinate the animation.

    For this reason, when you say “extract frames from a gif file” you could mean two things; each unique frame could be extracted just once, or each frame could be extracted for each unit of time it is visible. If you want the latter, you must then decide on a rate of frames per second.

    Also interesting: the timing is funny business. Minimum frame rates (per second) can be determined by the software displaying the GIF file (more info at the bottom of this page). This makes the number of frames in a film strip style export of frames hard to calculate. I workaround this problem by finding the frame with the shortest display time and divide all the other times by this number. This means animations where all frames are shown for three seconds will only produce one image for each frame. If this is not what you are looking for, try ImageMagick (convert.exe).

    Usage

    Here are a few cmd.exe examples showing basic calls.

    Animated GIF to PNG images

    C:\>gif2frames.exe at.gif

    Animated GIF to BMP images

    gif2frames at.gif -bmp

    Animated GIF to JPG images

    gif2frames at.gif -jpg

    Only unique frames

    gif2frames at.gif -png -unique

    Downloads

  • Top users WordPress plugin

    I wrote a new plugin to list the contributors to a WordPress website. The comment and post counts are added together, and the top X users are listed in a simple table alongside the counts.

    Download top-users-by-comment-plus-post-count.zip.

    Installation instructions

    1. Upload the `top-users-by-comment-plus-post-count` folder to the `/wp-content/plugins/` directory
    2. Activate the plugin through the ‘Plugins’ menu in WordPress
    3. Place this or a similar function call in your theme: <?php top_users_by_comment_plus_post_count( 10 ); ?>

    CSS sample

    This is the CSS I am using to style the output.

    #top-users-by-comment-plus-post-count td.tu-author{ padding-right: 8px; }
    #top-users-by-comment-plus-post-count td.tu-count{ text-align: right; }

    Sample output

    I added tab and line break characters for readability.

    <table id="top-users-by-comment-plus-post-count">
    	<tr><td class="tu-author">DisgustedInDenver</td><td class="tu-count">297</td></tr>
    	<tr><td class="tu-author">Corey</td><td class="tu-count">109</td></tr>
    	<tr><td class="tu-author">G11</td><td class="tu-count">60</td></tr>
    	<tr><td class="tu-author">jmbecker13</td><td class="tu-count">10</td></tr>
    	<tr><td class="tu-author">trustmedotcom</td><td class="tu-count">9</td></tr>
    	<tr><td class="tu-author">ulfwolf</td><td class="tu-count">8</td></tr>
    	<tr><td class="tu-author">noscamsforme</td><td class="tu-count">8</td></tr>
    	<tr><td class="tu-author">who8dapple</td><td class="tu-count">7</td></tr>
    	<tr><td class="tu-author">cindmo</td><td class="tu-count">7</td></tr>
    	<tr><td class="tu-author">nytemare4u</td><td class="tu-count">7</td></tr>
    </table>