Skip to content

Instantly share code, notes, and snippets.

@ericstone57
Created July 23, 2016 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericstone57/4079c7a9bf6b08dfa184d2e74d60379e to your computer and use it in GitHub Desktop.
Save ericstone57/4079c7a9bf6b08dfa184d2e74d60379e to your computer and use it in GitHub Desktop.
Combine image sequences as numbers of pics in a row which with multiple files. Depend on ImageMagic.
<?php
$from = 1;
$to = 360;
$figure_lenght = 4;
$pic_one_row = 3;
$file_prefix = "output_";
$file_extension = ".jpg";
$output_folder = "./result/";
$output_index = 1;
while ($from < $to) {
$str_pics = '';
for ($i = 0; $i < $pic_one_row; $i++) {
$filename = $file_prefix.str_pad($from+$i, $figure_lenght, 0, STR_PAD_LEFT).$file_extension;
if (file_exists("./".$filename)) {
$str_pics .= $filename." ";
}
}
exec("convert $str_pics +append $output_folder/result_" . str_pad($output_index, $figure_lenght, 0, STR_PAD_LEFT) . ".jpg");
print $output_index ."\n";
$output_index++;
$from += $pic_one_row;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment