Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mass image scanner (2008)
<?php
//scan_pics.php
//Mass image scanner for URLs.
//Valid known prefixes: DSC, DSCN, DSCF, DSC_, DSC, IMG, IMG_, Photo, PIC
//Valid suffixes: .jpg, .png (etc, keep in mind on linux servers file names are case sensitive, so searching for .JPG, .PNG may be useful, but cameras usually save them as lowercase .jpg), _DSCN.jpg (in rare cases)
//For more suffixes or prefixes read up on http://en.wikipedia.org/wiki/Design_rule_for_Camera_File_system
//Optimal usage: /scan_pics.php?url=http://filesmelt.com/dl/&prefix=DSC&suffix=.jpg
//You must edit the URL to your own likings.
//In the demonstration it was used on this URL with the DSC prefix although it only finds one photo.
//Additional parameters: &start=0, &end=9999 (most cameras only go up to 9999 so there's no point in going higher)
//The additional parameters are also good for certain number scans, i.e. from 600 to 699, such as trying to find a set of photos.
//All files that don't exist will error, any files that are found will appear as normal images.
//The page will take extremely long to load on a normal 0-9999 scan, you'll only know what has loaded and what hasn't when it's done loading.
//Functions used by script
function zerofill($mStretch, $iLength = 2)
{
$sPrintfString = '%0' . (int)$iLength . 's';
return sprintf($sPrintfString, $mStretch);
}
if(isset($_GET['start'])){
$start = $_GET['start'];
}else{
$start = 0;
}
if(isset($_GET['end'])){
if($_GET['end'] <= 9999){
$end = $_GET['end'];
}else{
$end = 9999;
}
}else{
$end = 9999;
}
if(isset($_GET['url'])){
$url = $_GET['url'];
}else{
die('No parameters specified.');
}
if(isset($_GET['prefix'])){
$prefix = $_GET['prefix'];
}else{
$prefix = null;
}
if(isset($_GET['suffix'])){
$suffix = $_GET['suffix'];
}else{
$suffix = '.jpg';
}
echo '<title>Scanning images from '.$prefix.$start.$suffix.' to '.$prefix.$end.$suffix.'.</title>';
for($i=$start;$i<$end + 1;$i++){
echo '<img src="'.$url.$prefix.zerofill($i,strlen($end)).$suffix.'" width="100" height="100" />';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment