Skip to content

Commit

Permalink
Synced & combed for 1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
xparq committed May 23, 2014
1 parent 090e2f8 commit ffe0396
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,29 @@ AnimGif is a PHP class to create animated GIFs -- just list the source images (i
**1. Creation:**

```php
// Create an array containing file paths, resource vars (initialized with imagecreatefromXXX),
// image URLs or even binary image data. (All in the order as they should appear.)
// Use an array containing file paths, resource vars (initialized with imagecreatefromXXX),
// image URLs or binary image data.
$frames = array(
imagecreatefrompng("/../images/pic1.png"), // resource var
"/../images/pic2.png", // image file path
file_get_contents("/../images/pic3.jpg"), // image binary data
"http://thisisafakedomain.com/images/pic4.jpg", // URL
);

// Optionally, create an array with the durations (in 1/100s units) of every frame
$durations = array(10, 30, 10, 20);
// Or, load the image files from a dir (and sort them):
//$frames = "../images";

// Optionally, set the duration (in 1/100s units) for each frame
$durations = array(20, 30, 10, 10);

// Or, with the shorthand form (omitting the repetitions):
$durations = array(20, 30, 10);

// Initialize and create the GIF!
$anim = new GifCreator\AnimGif();
$anim->create($frames, $durations);

// Or, for just a default 100ms even delay:
// Or, for just use a default 100ms even delay:
//$anim->create($frames);

// Or, for 5 repeats & then stop:
Expand All @@ -43,15 +49,15 @@ $gif = $anim->get();

**3. Use it:**

Then you can send it to the browser:
Then you might send it directly to the browser:

```php
header("Content-type: image/gif");
echo $gif;
exit;
```

Or save it as a GIF file:
Or save it to a file:

```php
file_put_contents("animated.gif", $gif);
Expand All @@ -60,9 +66,8 @@ file_put_contents("animated.gif", $gif);

### Behavior

- Transparency is based on the first given frame. It will be saved only if you give multiple frames with the same transparent background.
- The dimensions of the generated GIF are based on the first frame. If you need to resize your frames to get the same dimensions, you can use
this class: https://github.com/Sybio/ImageWorkshop.
- Transparency is based on the first frame. [!!NOT VERIFIED: "It will be saved only if you give multiple frames with the same transparent background"]
- The dimensions of the generated GIF are based on the first frame, too. If you need to resize your images to get the same dimensions, you can use this class: https://github.com/Sybio/ImageWorkshop.


### Dependencies
Expand Down

0 comments on commit ffe0396

Please sign in to comment.