Kwarcek

Get images with multi ascending name

Aug 23rd, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. /* Get image from HTTP with ascending name */
  2.  
  3. /* Example
  4. https://example.com/images/0/0
  5. https://example.com/images/0/1
  6. https://example.com/images/1/0
  7. https://example.com/images/1/1
  8. */
  9.  
  10. for( $y = 0; $y <= 250; $y++ ) {
  11.  
  12. for( $x = 0; $x <= 10; $x++ ) {
  13.  
  14. $url = 'https://example.com/images/' . $y . '/' . $x . '.jpeg';
  15.  
  16. $locationURL = 'images/' . $y . '-' . $x . '.jpeg';
  17.  
  18. $file_headers = get_headers($url);
  19.  
  20. if(strpos($file_headers[0], '404') !== false){
  21. echo $url . " Doesn't exist !<br/>";
  22. } else {
  23.  
  24. $image = file_get_contents($url);
  25.  
  26. $img = new Imagick();
  27.  
  28. $img->readImageBlob($image);
  29.  
  30. $img->writeImage ($locationURL);
  31.  
  32. $img -> destroy(); 
  33. }
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment