2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ All notable changes to `:vips` will be documented in this file.
4
4
5
5
## master
6
6
7
+ - added ` animate-image.php ` example [ jcupitt]
8
+
7
9
## 2.3.0 - 2023-09-26
8
10
9
11
- add getFields() to fetch an array of field names [ jcupitt]
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env php
2
+ <?php
3
+
4
+ require dirname (__DIR__ ) . '/vendor/autoload.php ' ;
5
+ use Jcupitt \Vips ;
6
+
7
+ #Vips\Config::setLogger(new Vips\DebugLogger());
8
+
9
+ if (count ($ argv ) != 4 ) {
10
+ echo ("usage: ./animate-image.php input-image output-image 'text string' \n" );
11
+ exit (1 );
12
+ }
13
+
14
+ $ image = Vips \Image::newFromFile ($ argv [1 ]);
15
+ $ text = Vips \Image::text ($ argv [3 ], ["dpi " => 300 , "rgba " => true ]);
16
+ $ animation = NULL ;
17
+ $ delay = [];
18
+
19
+ for ($ x = 0 ; $ x < $ image ->width + $ text ->width ; $ x += 10 )
20
+ {
21
+ // append the frame to the image vertically ... we make a very tall, thin
22
+ // strip of frames to save
23
+ $ frame = $ image ->composite2 ($ text , "over " , [
24
+ "x " => $ x - $ text ->width ,
25
+ "y " => $ image ->height / 2 - $ text ->height / 2
26
+ ]);
27
+ if ($ animation == NULL )
28
+ $ animation = $ frame ;
29
+ else
30
+ $ animation = $ animation ->join ($ frame , "vertical " );
31
+
32
+ // frame delay in ms
33
+ array_push ($ delay , 30 );
34
+ }
35
+
36
+ // set animation properties
37
+ $ animation ->set ("delay " , $ delay );
38
+ $ animation ->set ("loop " , 0 );
39
+ $ animation ->set ("page-height " , $ image ->height );
40
+
41
+ $ animation ->writeToFile ($ argv [2 ]);
0 commit comments