Banner
Views: 236,227,200
Time: 2013-05-22 12:06:30 AM
15 users online: o BZM, EvilGuy0613, o FPzero, o Hadron, henrybros, jellybean, LostDoman, phenolatukas, Randomiser, RedRose64, Rextep, tylersuperwiigamer, o Undy, Usetheforce, Yoshi88 - Guests: 18 - Bots: 14Users: 22,858 (1,278 active)
Latest: FUNKY kong ending
Tip: Verify that your hack's IPS patch is functioning correctly before submitting it.
RELEASE: CutePop - a PHP GIF manipulation library
Forum Index - Hobbies - Computers & Technology - RELEASE: CutePop - a PHP GIF manipulation library
Pages: « 1 »
This is the initial release of CutePop, my GIF manipulation library for PHP. It's still pretty crude and it's feature set is somewhat unimpressive at the moment, but I have plans to make it quite extensive.

Current version: 20110504a

Download it here.

Features:
  • Load and save GIF files
  • Replace palette colors
  • Supports animated GIFs
  • Import and export frames
  • Change framerate
  • And some other bullshit...

Planned:
  • Compress/recompress image data
  • Image data manipulation

Noteworthy methods:

CutePop
CutePop_GifDataStream CutePop::factory ( void ) Returns an empty GIF data stream object.
CutePop_GifDataStream CutePop::fromFile ( string $filename ) Creates a GIF data stream object from a GIF file.
CutePop_GifDataStream
int CutePop_GifDataStream::getWidth ( void ) Returns the logical screen width for the data stream.
void CutePop_GifDataStream::setWidth ( int $width ) Sets the logical screen width for the data stream.
int CutePop_GifDataStream::getHeight ( void ) Returns the logical screen height for the data stream.
void CutePop_GifDataStream::setHeight ( int $height ) Sets the logical screen height for the data stream.
CutePop_ColorTable CutePop_GifDataStream::getColorTable ( void ) Returns the global color table object for the GIF stream.
void CutePop_GifDataStream::importColorTable ( CutePop_ColorTable $colorTable ) Import a color table object for use as global color table.
mixed CutePop_GifDataStream::getLoopCount ( void ) Returns NULL if the GIF is not animated. Otherwise returns amount of loops (0-65535, 0 = infinite).
void CutePop_GifDataStream::setLoopCount ( mixed $count ) Sets amount of loops for animated GIFs. See above for argument values.
int CutePop_GifDataStream::getImageCount ( void ) Return the number of images in the data stream.
CutePop_GifImage CutePop_GifDataStream::getImage ( int $index ) Return an image from the data stream.
void CutePop_GifDataStream::appendImage ( CutePop_GifImage $image ) Add an image to the data stream.
string CutePop_GifDataStream::render ( void ) Renders the data stream and returns the result as a string.
void CutePop_GifDataStream::saveAs ( string $filename [, bool $overwrite ] ) Renders the data stream and writes the result to a file.
CutePop_GifImage
int CutePop_GifImage::getDelayTime ( void ) Returns the duration of the image in 1/100ths of a second (animated GIFs only).
void CutePop_GifImage::setDelayTime ( int $delayTime ) Sets the duration of the image (animated GIFs only).
mixed CutePop_GifImage::getTransparentColorIndex ( void ) Returns the palette index for the transparent color or NULL if none is set.
void CutePop_GifImage::setTransparentColorIndex ( int $index ) Sets the palette index for the transparent color.
CutePop_ColorTable CutePop_GifImage::getColorTable ( void ) Returns the global color table object for the GIF stream.
void CutePop_GifImage::importColorTable ( CutePop_ColorTable $colorTable ) Import a color table object for use as global color table.
CutePop_ColorTable
int CutePop_ColorTable::getSize ( void ) Returns the color table size.
array CutePop_ColorTable::getColor ( int $index ) Returns the color at the specified index. Array format is array( 0 => $r, 1 => $g, 2 => $b ).
void CutePop_ColorTable::replaceColor ( int $index, int $r, int $g, int $b ) Replaces the color at the specified index.
void CutePop_ColorTable::replaceColor ( int $index, array $color ) See above. $color like array in getColor.


Usage examples:
  • Replace a palette color
    Code
    try { $gif = CutePop::fromFile('original.gif'); $gif->getColorTable()->replaceColor(1, 255, 128, 0); $gif->saveAs('new.gif'); } catch(Exception $e) { echo $e->getMessage(); }

  • Split a file
    Code
    try { $gif = CutePop::fromFile('original.gif'); for($i = 0; $i < $gif->getImageCount(); $i++) { $image = CutePop::factory(); $image->setWidth($gif->getWidth()); $image->setHeight($gif->getHeight()); $colorTable = $gif->getColorTable(); if($colorTable !== NULL) { $image->importColorTable($colorTable); } $image->appendImage($gif->getImage($i)); $image->saveAs($i . '.gif'); } } catch(Exception $e) { echo $e->getMessage(); }

  • Merge files (assuming they are all the same size)
    Code
    try { $gif = CutePop::factory(); foreach(glob('*.gif') as $filename) { $tmp = CutePop::fromFile($filename); if(!$gif->getWidth()) { $gif->setWidth($tmp->getWidth()); $gif->setHeight($tmp->getHeight()); $colorTable = $tmp->getColorTable(); if($colorTable !== NULL) { $gif->importColorTable($colorTable); } } $tmpImage = $tmp->getImage(0); $tmpImage->setDelayTime(5); $gif->appendImage($tmpImage); } $gif->setLoopCount(0); $gif->saveAs('animated.gif'); } catch(Exception $e) { echo $e->getMessage(); }


DISCLAIMER: ALL EXAMPLES ARE UNTESTED. I CANNOT BE HELD RESPONSIBLE IF THIS SOFTWARE MAKES YOUR COMPUTER EXPLODE.
Oooh... shiny PHP. I was just wondering how you got all those different colored poptart cats!

Sadly, I don't have any real use for it. Nice to see you've made something new, though!
That's actually pretty darn cool. I admittedly don't do much with PHP besides basic forms/dynamic pages, but this looks nice.
I don't know if this'd be possible, but it'd be cool if you could take a non-animated GIF and plug an array of colors into it to make palette animation. Now that I think about it, it should be entirely possible. If you make something that can do palette cycles/animations with pure PHP, I'll give you a cookie. #w{=3}
Pages: « 1 »
Forum Index - Hobbies - Computers & Technology - RELEASE: CutePop - a PHP GIF manipulation library

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu