Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish an example #5

Open
wants to merge 122 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
a4d16d5
Refer to Sybio's original stuff.
xparq Apr 24, 2014
2295761
Code cosmetics (untested yet for regressions!)
xparq Apr 24, 2014
78d9f6e
Fix encodeAsciiToChar() call (no $this-> any more).
xparq Apr 24, 2014
28fc1b4
Sync with name changes, added "Dependencies"
xparq Apr 24, 2014
440de99
Moved namespace from the title to the code samples.
xparq Apr 24, 2014
7f569c1
Renamed class from GifCreator to AnimGif
xparq Apr 24, 2014
cb7db12
Various small improvements.
xparq Apr 24, 2014
1e21c50
Formatting fix.
xparq Apr 24, 2014
1e6e541
Minor cosmetics.
xparq Apr 24, 2014
43befb1
Removed confusing "working copy" stuff etc.
xparq Apr 24, 2014
0320fa4
Wording...
xparq Apr 24, 2014
954f06d
Changed "About" to "Credits"
xparq Apr 24, 2014
0eb7205
Moved Credits down, Dependencies up
xparq Apr 24, 2014
fd8ca5f
Typo
xparq Apr 24, 2014
581ce6f
Messed with it -- highly suspect it broken now!
xparq Apr 24, 2014
2684620
Renamed the source file (from GifCreator.php)
xparq Apr 24, 2014
6f4be7e
Moved the `namespace` stmt. above `define()`
xparq Apr 24, 2014
ebe0f8a
Cut leftover "public" from encodeAsciiToChar()
xparq Apr 24, 2014
0e3734f
Prettified link to GifCreator etc.
xparq Apr 24, 2014
d11d02f
Fix leftover $GIF_tim name in create()
xparq Apr 24, 2014
681e9f4
Support even timing without an array, fix ERR00.
xparq Apr 24, 2014
0a733c6
Added example for even timing & infinite loop default
xparq Apr 24, 2014
b29c9f1
$duration default = 40ms, $frames no longer optional in create()
xparq Apr 24, 2014
37f7d74
Iterate with foreach in create(), leftover $mode deleted.
xparq Apr 24, 2014
5982da6
Typos
xparq Apr 24, 2014
cb9f997
Added todo for fixing broken "direct GIF" example.
xparq Apr 24, 2014
73b5631
Todo added for wrong(?) anim delay
xparq Apr 24, 2014
44b01ca
Cosmetics, GIF example OK.
xparq Apr 24, 2014
74e33d7
Removed redundant & non-std. Content-Disposition header
xparq Apr 24, 2014
da6c88e
Fix ERR01 ("Resource is not a GIF image.")
xparq Apr 24, 2014
bb1ecce
Updated the GitHub URL after the repo rename
xparq Apr 24, 2014
92fb5b4
Call it "version 1.1", not "1.1-lunakid"
xparq Apr 24, 2014
a785d48
Cosmetics
xparq Apr 24, 2014
9d41916
Fork-note updated
xparq Apr 24, 2014
adbf1c2
Update README.md
xparq Apr 24, 2014
e3999a0
Small fixes
xparq Apr 24, 2014
a88de0a
Better descr. line
xparq Apr 24, 2014
f8352a9
Examples extended, explanations less verbose.
xparq Apr 24, 2014
9cbbc1d
Some styling
xparq Apr 24, 2014
5f5e49c
Typo, shorter example filename
xparq Apr 24, 2014
250b5c6
Some cleaning of the CHANGES comment
xparq Apr 24, 2014
9de7c64
Updated the meta stuff only, but NOT TESTED!
xparq Apr 24, 2014
7b82e97
Fixed delay unit mismatch
xparq Apr 25, 2014
340af3e
Fixed delay time unit
xparq Apr 25, 2014
915067c
Fork-note updated
xparq Apr 25, 2014
a6b2803
More accurate credits
xparq Apr 25, 2014
5193248
Punctuation
xparq Apr 25, 2014
cb97843
Fixed yet anohter leftover ms value
xparq Apr 25, 2014
036be61
Changed default delay time to 100ms.
xparq Apr 25, 2014
87e0e8e
Synced with the new default delay
xparq Apr 25, 2014
6be1a13
file_exists() -> @file_readable()
xparq Apr 25, 2014
6c0c3be
Better ERR002
xparq Apr 25, 2014
c4647b9
Added error: "Loading from URLs is disabled by PHP"
xparq Apr 25, 2014
c99d167
Some wording, formatting
xparq Apr 25, 2014
000f538
$gifBinary -> $gif
xparq Apr 25, 2014
d55d069
Wording
xparq Apr 25, 2014
23a7342
Changelog corrections
xparq Apr 25, 2014
c10865a
Phrasing
xparq Apr 25, 2014
5db98f7
Link to Sybio
xparq Apr 25, 2014
feee04e
Fix regression (mistyped is_readable)
xparq Apr 25, 2014
647ea74
Rename encodeAsciiToChar() -> word2bin()
xparq Apr 25, 2014
c4ce9d7
Amended the changelog.
xparq Apr 25, 2014
46018cc
Mention "little-endian" at word2bin()
xparq Apr 25, 2014
4fd30b0
Added Matthew Flickinger's GIF page to Credits.
xparq Apr 25, 2014
a44b549
(Added quote bar for the taste of it.)
xparq Apr 25, 2014
5928ce4
Missing quotes around 'VERSION'
xparq Apr 30, 2014
d20b91c
Create CHANGES.txt
xparq May 17, 2014
2f9345f
Add more todo.
xparq May 17, 2014
986e50e
Mention scandir.
xparq May 17, 2014
942895c
Menetion file saving example & SO
xparq May 17, 2014
d08c910
Added image load error checking.
xparq May 17, 2014
73f280b
typo (syntax error)
xparq May 17, 2014
4941e94
Generalized load error checking to cover format errors, too.
xparq May 17, 2014
8d0dd98
Add more todo.
xparq May 17, 2014
c8bb678
Be more explicit about the nature of this fork.
xparq May 17, 2014
9d44688
Stop mixing ' and ", remove folder from file_put_contents().
xparq May 17, 2014
bdf6557
Rephrase ERR02.
xparq May 17, 2014
0aacf22
Preserve frame name + slightly clearer flow for non-resources in clea…
xparq May 17, 2014
4fd80eb
Preserve frame name + slightly clearer flow for non-resources in crea…
xparq May 17, 2014
953e0a2
Transparent-color-handling code normalized.
xparq May 17, 2014
65cfb15
Use previous delay by default.
xparq May 17, 2014
47d3575
Pointers to external (no longer in-file) change docs.
xparq May 17, 2014
42cf67b
Refer to GitHub releases and commits.
xparq May 17, 2014
d21dda9
Error handling improved.
xparq May 17, 2014
bfe48b5
Phrasing...
xparq May 17, 2014
276802c
Add the multi-delay bug.
xparq May 17, 2014
6ca5608
VERSION: define() -> const (namespaced!)
xparq May 17, 2014
c218961
Fix: 'VERSION' -> VERSION
xparq May 17, 2014
a74c2e9
Typo
xparq May 17, 2014
ac25ba2
Reprod. details for the delay bug.
xparq May 17, 2014
8496704
Fix version nr.
xparq May 17, 2014
15acbe7
More todo.
xparq May 17, 2014
cfc9725
More todo.
xparq May 17, 2014
70998d7
Fixed todo for save().
xparq May 17, 2014
92ed512
Added API call $->save($filename)
xparq May 17, 2014
d7312b3
Move $->save($name) to release notes.
xparq May 17, 2014
d978359
Version bumped to 1.3-pre+ ("rolling pre-release")
xparq May 17, 2014
fdcb5bb
Make reset() public & fix 2 typos in it.
xparq May 23, 2014
c346a76
Added image dir source.
xparq May 23, 2014
5fdc035
Version to 1.3 & fix return from create().
xparq May 23, 2014
9a260b9
Add slideshow example for convenience.
xparq May 23, 2014
090e2f8
Removed stuff already in the new release notes.
xparq May 23, 2014
ffe0396
Synced & combed for 1.3.
xparq May 23, 2014
36bceba
Example for selective omission of delays.
xparq May 23, 2014
7864cc4
Add a missing //
xparq May 23, 2014
73b476c
Mention new methods
xparq May 23, 2014
71f5f98
Change old file_put_contents() to $->save()
xparq May 23, 2014
449aa6f
Streamlined the usage part a bit.
xparq May 23, 2014
b71d3f8
Minor clarification
xparq May 23, 2014
ca70ed6
Rename index.php to test/index.php
xparq May 31, 2014
aa66a57
Moved test stuff to test/.
xparq May 31, 2014
2fb80d5
Image dir added
xparq May 31, 2014
3970dea
Skip .files in image dirs (for now).
xparq May 31, 2014
d631010
Restructure the example section a bit
xparq May 31, 2014
007c734
Some clarifications
xparq May 31, 2014
8a298df
Todo item added
xparq May 31, 2014
3a385cb
Fixes Non-Looped GIFs
lucanos Oct 13, 2016
1676cb2
Merge pull request #1 from lucanos/master
xparq Dec 15, 2016
9c81a3a
Cosmetics
xparq Mar 6, 2017
0b388f5
Some more redundant pondering while watching an 1969 absurd movie...
xparq Mar 7, 2017
76197ca
Corrected typo in GIF header generation, fixes #2
philklc Oct 25, 2017
7140162
Merge pull request #4 from philklc/patch-1
xparq Dec 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
TODO:

! Allow image dirs within the input list (array), too, not only instead of it.

! In local testing I had a strange issue with by-frame delays: the first image eats
up the first two delays, and is shown for the sum of those two numbers... :-o
-> And I seem to be unable to reproduce it now! :-o

* Warn about explicit sorting if per-frame delays are specified for a dir source?

* Sync the index.php (demo & quickstart frontend) with the examples in README.md
AND ALSO THE ONE AT SO!

* To avoid unwanted "in-band" PHP output, I should probably disable display_errors()
in the whole module (restoring it on normal exit)...


------------------------------------------------------------------------------------
DONE:

-> Release notes: https://github.com/lunakid/AnimGif/releases/
-> See also the GitHub commit history: https://github.com/lunakid/AnimGif/commits/
87 changes: 53 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,86 @@
# ================================
# GifCreator
# ================================
> *NOTE: This is a fork of [Clément Guillemain](https://github.com/Sybio)'s nice [GifCreator class](https://github.com/Sybio/GifCreator), with some API changes (class rename, new & updated methods, more flexible (and robust) parameter handling etc.), better error handling, several small corrections, code cosmetics & other improvements scattered all across.*

GifCreator is a PHP class to create animated GIF from multiple images
### About

### For what ?
AnimGif is a PHP class to create animated GIFs -- just list the source images (in various forms), and that's it!

This class helps you to create an animated GIF image: give multiple images and their duration and that's it !

### Usage

**1 - Creation:**
**1. Inputs:**

```php
// Create an array containing file paths, resource var (initialized with imagecreatefromXXX),
// image URLs or even binary code from image files.
// All sorted in order to 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"), // Binary source code
'http://thisisafakedomain.com/images/pic4.jpg', // URL
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
);

// Create an array containing the duration (in millisecond) of each frames (in order too)
$durations = array(40, 80, 40, 20);
// Or: load images from a dir (sorted, skipping .files):
//$frames = "../images";

// Initialize and create the GIF !
$gc = new GifCreator();
$gc->create($frames, $durations, 5);
// Optionally: set different durations (in 1/100s units) for each frame
$durations = array(20, 30, 10, 10);

// Or: you can leave off repeated values from the end:
//$durations = array(20, 30, 10); // use 10 for the rest
// Or: use 'null' anywhere to re-apply the previous delay:
//$durations = array(250, null, null, 500);
```

**2. Create the GIF:**

``` php
$anim = new GifCreator\AnimGif();
$anim->create($frames, $durations);

// Or: using the default 100ms even delay:
//$anim->create($frames);

// Or: loop 5 times, then stop:
//$anim->create($frames, $durations, 5); // default: infinite looping
```
The 3rd parameter of create() method allows you to choose the number of loop of your animated gif before it stops.
In the previous example, I chose 5 loops. Set 0 (zero) to get an infinite loop.

**2 - Get the result:**
**3. Get/use the result:**

You can now get the animated GIF binary:

```php
$gifBinary = $gc->getGif();
$gif = $anim->get();
```

Then you can show it in the navigator:
...and e.g. send it directly to the browser:

```php
header('Content-type: image/gif');
header('Content-Disposition: filename="butterfly.gif"');
echo $gifBinary;
header("Content-type: image/gif");
echo $gif;
exit;
```

Or save it in a folder as a GIF:
Or just save it to a file:

```php
file_put_contents('/myfolder/animated_picture.gif', $gifBinary);
$anim->save("animated.gif");
```


### Behavior

- The transparency is based on the first given frame. It will be saved only if you give multiple frames with 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 dimension, 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

* PHP 5.3 (for namespace support & whatnot; noone still shamelessly uses PHP < 5.3, right?!)
* GD (`imagecreatefromstring`, `imagegif`, `imagecolortransparent`)


### About
### Credits

The class reuses some part of code of "GIFEncoder.class.php" by László Zsidi (thanks to him).
* László Zsidi: All the tough parts come from his [GIFEncoder.class.php](http://www.phpclasses.org/package/3163) (also found [here, in a Gist](https://gist.github.com/allometry/1438842)). Thanks, Laci!
* Clément Guillemain: for the very handy, redesigned (& "classified") API, extensions and nice docs!
* Matthew Flickinger: for his amazing, unbeatable [GIF format dissection page](http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp).
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{
"name": "sybio/gif-creator",
"name": "lunakid/anim-gif",
"type": "library",
"description": "PHP class that creates animated GIF from multiple images",
"description": "PHP class to create an animated GIF from multiple images",
"keywords": ["gif", "animated", "creation", "encode", "PHP"],
"homepage": "https://github.com/Sybio/GifCreator",
"homepage": "https://github.com/lunakid/AnimGif",
"license": "MIT",
"authors": [
{
"name": "Clément Guillemain",
"homepage": "http://clementguillemain.fr",
"role": "Developer / Freelancer"
},
{
"name": "Szabolcs Szász",
"homepage": "http://github.com/lunakid",
"role": "Developer / Freelancer"
}
],
"require": {
Expand All @@ -18,4 +23,4 @@
"autoload": {
"psr-0": { "GifCreator": "src" }
}
}
}
Loading