Ejemplo n.º 1
0
 public function getCompile()
 {
     $maps = json_decode(file_get_contents(FileHandler::path() . 'maps.json'));
     $zoom = '1';
     // https://www.google.com/search?q=image+magick+grid+combine&oq=image+magick+grid+combine
     // http://gotofritz.net/blog/geekery/combining-images-imagemagick/
     // convert *.png -gravity south -splice 0x111 -shave 0x111 -resize 400x400  converted.png
     // montage converted*.png -mode concatenate  -tile 2x2  output.png
     $map_base_path = base_path() . '/resources/assets/maps/';
     $compiled_folder = $map_base_path . 'compiled/';
     foreach ($maps as $id => $sub_maps) {
         #if ($id != 54) continue; // TESTING
         foreach ($sub_maps as $map) {
             $original_folder = $map_base_path . 'original/' . $map->MAPID . '/';
             $compiled_name = strtolower(str_replace(' ', '-', $map->ZONE . '-' . $map->REGION)) . '-' . str_replace('/', '-', $map->MAPID) . '.png';
             if (count($map->BPOINT) + count($map->MPOINT) != 0) {
                 $compiled_name = '_' . $compiled_name;
             }
             $x = $y = 0;
             foreach (range(0, 15) as $i) {
                 $had_file = false;
                 foreach (range(0, 15) as $j) {
                     // i then j gets us up to down
                     // j then i gets us left to right
                     $filename = $zoom . '_' . $i . '_' . $j . '.png';
                     if (!is_file($original_folder . $filename)) {
                         break;
                     }
                     $had_file = true;
                     $y = $j;
                 }
                 if (!$had_file) {
                     break;
                 }
                 $x = $i;
             }
             $x++;
             $y++;
             exec('montage ' . $original_folder . '*.png -mode concatenate -tile ' . $x . 'x' . $y . ' ' . $compiled_folder . $compiled_name);
         }
     }
     flash()->message('Map Image Compiler finished');
     return redirect('/osmose');
 }