Skip to content

Instantly share code, notes, and snippets.

@jakebathman
Created May 10, 2018 13:57
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 jakebathman/0811ec1a6d7d4313abfd8bf0a843d238 to your computer and use it in GitHub Desktop.
Save jakebathman/0811ec1a6d7d4313abfd8bf0a843d238 to your computer and use it in GitHub Desktop.
Scrape the IGN Fortnite map tiles and re-construct a large map image
<?php
/*****
If you have PHP installed, run this from the command line:
php scrape_ign_fortnite_map_tiles.php
**/
ini_set('memory_limit','2048M');
$baseUrl="http://oyster.ignimgs.com/ignmedia/wikimaps/fortnite/season4v1-hi-res/6/";
$xMax = 63;
$yMax = 63;
$dirPrefix="./tiles/";
$totalCount = ($xMax+1)*($yMax+1);
for($x=0;$x<=$xMax;$x++){
for($y=0;$y<=$yMax;$y++){
$filename = "$x-$y.jpg";
$i++;
echo "[".number_format((100*($i/$totalCount)),2)."%] ";
if(file_exists($dirPrefix.$filename) === false){
echo "Downloading $filename\n";
file_put_contents($dirPrefix.$filename, file_get_contents($baseUrl.$filename));
}
else{
echo "Already have $filename\n";
}
}
}
if($i == $totalCount){
// Merge images
echo "Merging images...\n";
// Get overall image dimensions
list($w, $h) = getimagesize($dirPrefix."0-0.jpg");
$width = $w * ($xMax+1);
$height = $h * ($yMax+1);
echo "creating base...$width x $height\n";
// Create the big base to fill
$map = imagecreatetruecolor($width,$height);
for($x=0;$x<=$xMax;$x++){
for($y=0;$y<=$yMax;$y++){
echo "$x-$y\n";
imagecopy(
$map,
imagecreatefromjpeg($dirPrefix."$x-$y.jpg"),
$x * $w,
$y * $h,
0,
0,
$w,
$h
);
}
}
}
imagejpeg($map, 'map.jpg');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment