diff --git a/robohash/robohash.py b/robohash/robohash.py index 3bf6d9d..7f0d105 100644 --- a/robohash/robohash.py +++ b/robohash/robohash.py @@ -33,7 +33,7 @@ class Robohash(object): #3 = BG self.iter = 4 self._create_hashes(hashcount) - + self.resourcedir = os.path.dirname(__file__) + '/' # Get the list of backgrounds and RobotSets self.sets = self._listdirs(self.resourcedir + 'sets') @@ -53,12 +53,12 @@ class Robohash(object): # This ensures that /Bear.png and /Bear.bmp will send back the same image, in different formats. if string.lower().endswith(('.png','.gif','.jpg','.bmp','.jpeg','.ppm','.datauri')): - format = string[string.rfind('.') +1 :len(string)] + format = string[string.rfind('.') +1 :len(string)] if format.lower() == 'jpg': - format = 'jpeg' - self.format = format - string = string[0:string.rfind('.')] - return string + format = 'jpeg' + self.format = format + string = string[0:string.rfind('.')] + return string def _create_hashes(self,count): @@ -71,7 +71,7 @@ class Robohash(object): blocksize = int(len(self.hexdigest) / count) currentstart = (1 + i) * blocksize - blocksize currentend = (1 +i) * blocksize - self.hasharray.append(int(self.hexdigest[currentstart:currentend],16)) + self.hasharray.append(int(self.hexdigest[currentstart:currentend],16)) def _listdirs(self,path): return [d for d in natsort.natsorted(os.listdir(path)) if os.path.isdir(os.path.join(path, d))] @@ -90,7 +90,7 @@ class Robohash(object): if name[:1] is not '.': directories.append(os.path.join(root, name)) directories = natsort.natsorted(directories) - + # Go through each directory in the list, and choose one file from each. # Add this file to our master list of robotparts. for directory in directories: @@ -98,7 +98,7 @@ class Robohash(object): for imagefile in natsort.natsorted(os.listdir(directory)): files_in_dir.append(os.path.join(directory,imagefile)) files_in_dir = natsort.natsorted(files_in_dir) - + # Use some of our hash bits to choose which file element_in_list = self.hasharray[self.iter] % len(files_in_dir) chosen_files.append(files_in_dir[element_in_list]) @@ -125,7 +125,7 @@ class Robohash(object): # Only set1 is setup to be color-seletable. The others don't have enough pieces in various colors. - # This could/should probably be expanded at some point.. + # This could/should probably be expanded at some point.. # Right now, this feature is almost never used. ( It was < 44 requests this year, out of 78M reqs ) if roboset == 'set1': @@ -139,7 +139,7 @@ class Robohash(object): if bgset in self.bgsets: bgset = bgset elif bgset == 'any': - bgset = self.bgsets[ self.hasharray[2] % len(self.bgsets) ] + bgset = self.bgsets[ self.hasharray[2] % len(self.bgsets) ] # If we set a format based on extension earlier, use that. Otherwise, PNG. if format is None: @@ -154,7 +154,7 @@ class Robohash(object): # For instance, the head has to go down BEFORE the eyes, or the eyes would be hidden. # First, we'll get a list of parts of our robot. - + roboparts = self._get_list_of_files(self.resourcedir + 'sets/' + roboset) print(roboparts) @@ -169,12 +169,12 @@ class Robohash(object): if not ls.startswith("."): bglist.append(self.resourcedir + 'backgrounds/' + bgset + "/" + ls) background = bglist[self.hasharray[3] % len(bglist)] - + # Paste in each piece of the Robot. roboimg = Image.open(roboparts[0]) roboimg = roboimg.resize((1024,1024)) for png in roboparts: - img = Image.open(png) + img = Image.open(png) img = img.resize((1024,1024)) roboimg.paste(img,(0,0),img) @@ -183,13 +183,13 @@ class Robohash(object): #Flatten bmps r, g, b, a = roboimg.split() roboimg = Image.merge("RGB", (r, g, b)) - + if bgset is not None: bg = Image.open(background) bg = bg.resize((1024,1024)) bg.paste(roboimg,(0,0),roboimg) - roboimg = bg - - self.img = roboimg.resize((sizex,sizey),Image.ANTIALIAS) + roboimg = bg + + self.img = roboimg.resize((sizex,sizey),Image.ANTIALIAS) self.format = format diff --git a/robohash/sets/set4/000#00body/000#body0.png b/robohash/sets/set4/000#00body/000#body0.png new file mode 100644 index 0000000..d475d88 Binary files /dev/null and b/robohash/sets/set4/000#00body/000#body0.png differ diff --git a/robohash/sets/set4/000#00body/001#body1.png b/robohash/sets/set4/000#00body/001#body1.png new file mode 100644 index 0000000..69a5887 Binary files /dev/null and b/robohash/sets/set4/000#00body/001#body1.png differ diff --git a/robohash/sets/set4/000#00body/002#body2.png b/robohash/sets/set4/000#00body/002#body2.png new file mode 100644 index 0000000..c204045 Binary files /dev/null and b/robohash/sets/set4/000#00body/002#body2.png differ diff --git a/robohash/sets/set4/000#00body/003#body3.png b/robohash/sets/set4/000#00body/003#body3.png new file mode 100644 index 0000000..ecb0efa Binary files /dev/null and b/robohash/sets/set4/000#00body/003#body3.png differ diff --git a/robohash/sets/set4/000#00body/004#body4.png b/robohash/sets/set4/000#00body/004#body4.png new file mode 100644 index 0000000..662c097 Binary files /dev/null and b/robohash/sets/set4/000#00body/004#body4.png differ diff --git a/robohash/sets/set4/000#00body/005#body5.png b/robohash/sets/set4/000#00body/005#body5.png new file mode 100644 index 0000000..1531aab Binary files /dev/null and b/robohash/sets/set4/000#00body/005#body5.png differ diff --git a/robohash/sets/set4/000#00body/006#body6.png b/robohash/sets/set4/000#00body/006#body6.png new file mode 100644 index 0000000..d522ee8 Binary files /dev/null and b/robohash/sets/set4/000#00body/006#body6.png differ diff --git a/robohash/sets/set4/000#00body/007#body7.png b/robohash/sets/set4/000#00body/007#body7.png new file mode 100644 index 0000000..a13d687 Binary files /dev/null and b/robohash/sets/set4/000#00body/007#body7.png differ diff --git a/robohash/sets/set4/000#00body/008#body8.png b/robohash/sets/set4/000#00body/008#body8.png new file mode 100644 index 0000000..76d63de Binary files /dev/null and b/robohash/sets/set4/000#00body/008#body8.png differ diff --git a/robohash/sets/set4/000#00body/009#body9.png b/robohash/sets/set4/000#00body/009#body9.png new file mode 100644 index 0000000..1e4cdb6 Binary files /dev/null and b/robohash/sets/set4/000#00body/009#body9.png differ diff --git a/robohash/sets/set4/000#00body/010#body10.png b/robohash/sets/set4/000#00body/010#body10.png new file mode 100644 index 0000000..6fe6a83 Binary files /dev/null and b/robohash/sets/set4/000#00body/010#body10.png differ diff --git a/robohash/sets/set4/000#00body/011#body11.png b/robohash/sets/set4/000#00body/011#body11.png new file mode 100644 index 0000000..8aece5d Binary files /dev/null and b/robohash/sets/set4/000#00body/011#body11.png differ diff --git a/robohash/sets/set4/000#00body/012#body12.png b/robohash/sets/set4/000#00body/012#body12.png new file mode 100644 index 0000000..02dadb5 Binary files /dev/null and b/robohash/sets/set4/000#00body/012#body12.png differ diff --git a/robohash/sets/set4/000#00body/013#body13.png b/robohash/sets/set4/000#00body/013#body13.png new file mode 100644 index 0000000..99cd089 Binary files /dev/null and b/robohash/sets/set4/000#00body/013#body13.png differ diff --git a/robohash/sets/set4/000#00body/014#body14.png b/robohash/sets/set4/000#00body/014#body14.png new file mode 100644 index 0000000..ff9c2c4 Binary files /dev/null and b/robohash/sets/set4/000#00body/014#body14.png differ diff --git a/robohash/sets/set4/001#01fur/000#fur0.png b/robohash/sets/set4/001#01fur/000#fur0.png new file mode 100644 index 0000000..48e4ecb Binary files /dev/null and b/robohash/sets/set4/001#01fur/000#fur0.png differ diff --git a/robohash/sets/set4/001#01fur/001#fur1.png b/robohash/sets/set4/001#01fur/001#fur1.png new file mode 100644 index 0000000..693f50c Binary files /dev/null and b/robohash/sets/set4/001#01fur/001#fur1.png differ diff --git a/robohash/sets/set4/001#01fur/002#fur2.png b/robohash/sets/set4/001#01fur/002#fur2.png new file mode 100644 index 0000000..83312c9 Binary files /dev/null and b/robohash/sets/set4/001#01fur/002#fur2.png differ diff --git a/robohash/sets/set4/001#01fur/003#fur3.png b/robohash/sets/set4/001#01fur/003#fur3.png new file mode 100644 index 0000000..f0cb787 Binary files /dev/null and b/robohash/sets/set4/001#01fur/003#fur3.png differ diff --git a/robohash/sets/set4/001#01fur/004#fur4.png b/robohash/sets/set4/001#01fur/004#fur4.png new file mode 100644 index 0000000..27d7382 Binary files /dev/null and b/robohash/sets/set4/001#01fur/004#fur4.png differ diff --git a/robohash/sets/set4/001#01fur/005#fur5.png b/robohash/sets/set4/001#01fur/005#fur5.png new file mode 100644 index 0000000..7571b2d Binary files /dev/null and b/robohash/sets/set4/001#01fur/005#fur5.png differ diff --git a/robohash/sets/set4/001#01fur/006#fur6.png b/robohash/sets/set4/001#01fur/006#fur6.png new file mode 100644 index 0000000..fadb488 Binary files /dev/null and b/robohash/sets/set4/001#01fur/006#fur6.png differ diff --git a/robohash/sets/set4/001#01fur/007#fur7.png b/robohash/sets/set4/001#01fur/007#fur7.png new file mode 100644 index 0000000..536d6ff Binary files /dev/null and b/robohash/sets/set4/001#01fur/007#fur7.png differ diff --git a/robohash/sets/set4/001#01fur/008#fur8.png b/robohash/sets/set4/001#01fur/008#fur8.png new file mode 100644 index 0000000..0ae8704 Binary files /dev/null and b/robohash/sets/set4/001#01fur/008#fur8.png differ diff --git a/robohash/sets/set4/001#01fur/009#fur9.png b/robohash/sets/set4/001#01fur/009#fur9.png new file mode 100644 index 0000000..4f6d18b Binary files /dev/null and b/robohash/sets/set4/001#01fur/009#fur9.png differ diff --git a/robohash/sets/set4/002#02eyes/000#eyes0.png b/robohash/sets/set4/002#02eyes/000#eyes0.png new file mode 100644 index 0000000..179be45 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/000#eyes0.png differ diff --git a/robohash/sets/set4/002#02eyes/001#eyes1.png b/robohash/sets/set4/002#02eyes/001#eyes1.png new file mode 100644 index 0000000..5c5b33e Binary files /dev/null and b/robohash/sets/set4/002#02eyes/001#eyes1.png differ diff --git a/robohash/sets/set4/002#02eyes/002#eyes2.png b/robohash/sets/set4/002#02eyes/002#eyes2.png new file mode 100644 index 0000000..0c8833a Binary files /dev/null and b/robohash/sets/set4/002#02eyes/002#eyes2.png differ diff --git a/robohash/sets/set4/002#02eyes/003#eyes3.png b/robohash/sets/set4/002#02eyes/003#eyes3.png new file mode 100644 index 0000000..eb5c4bc Binary files /dev/null and b/robohash/sets/set4/002#02eyes/003#eyes3.png differ diff --git a/robohash/sets/set4/002#02eyes/004#eyes4.png b/robohash/sets/set4/002#02eyes/004#eyes4.png new file mode 100644 index 0000000..1886df7 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/004#eyes4.png differ diff --git a/robohash/sets/set4/002#02eyes/005#eyes5.png b/robohash/sets/set4/002#02eyes/005#eyes5.png new file mode 100644 index 0000000..0d81a8c Binary files /dev/null and b/robohash/sets/set4/002#02eyes/005#eyes5.png differ diff --git a/robohash/sets/set4/002#02eyes/006#eyes6.png b/robohash/sets/set4/002#02eyes/006#eyes6.png new file mode 100644 index 0000000..7d8e579 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/006#eyes6.png differ diff --git a/robohash/sets/set4/002#02eyes/007#eyes7.png b/robohash/sets/set4/002#02eyes/007#eyes7.png new file mode 100644 index 0000000..e7c62da Binary files /dev/null and b/robohash/sets/set4/002#02eyes/007#eyes7.png differ diff --git a/robohash/sets/set4/002#02eyes/008#eyes8.png b/robohash/sets/set4/002#02eyes/008#eyes8.png new file mode 100644 index 0000000..9d68abf Binary files /dev/null and b/robohash/sets/set4/002#02eyes/008#eyes8.png differ diff --git a/robohash/sets/set4/002#02eyes/009#eyes9.png b/robohash/sets/set4/002#02eyes/009#eyes9.png new file mode 100644 index 0000000..058fb7d Binary files /dev/null and b/robohash/sets/set4/002#02eyes/009#eyes9.png differ diff --git a/robohash/sets/set4/002#02eyes/010#eyes10.png b/robohash/sets/set4/002#02eyes/010#eyes10.png new file mode 100644 index 0000000..6652fff Binary files /dev/null and b/robohash/sets/set4/002#02eyes/010#eyes10.png differ diff --git a/robohash/sets/set4/002#02eyes/011#eyes11.png b/robohash/sets/set4/002#02eyes/011#eyes11.png new file mode 100644 index 0000000..1db5009 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/011#eyes11.png differ diff --git a/robohash/sets/set4/002#02eyes/012#eyes12.png b/robohash/sets/set4/002#02eyes/012#eyes12.png new file mode 100644 index 0000000..1c1e0c1 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/012#eyes12.png differ diff --git a/robohash/sets/set4/002#02eyes/013#eyes13.png b/robohash/sets/set4/002#02eyes/013#eyes13.png new file mode 100644 index 0000000..aa9cb50 Binary files /dev/null and b/robohash/sets/set4/002#02eyes/013#eyes13.png differ diff --git a/robohash/sets/set4/002#02eyes/014#eyes14.png b/robohash/sets/set4/002#02eyes/014#eyes14.png new file mode 100644 index 0000000..d8b4ace Binary files /dev/null and b/robohash/sets/set4/002#02eyes/014#eyes14.png differ diff --git a/robohash/sets/set4/003#03mouth/000#mouth0.png b/robohash/sets/set4/003#03mouth/000#mouth0.png new file mode 100644 index 0000000..678a27c Binary files /dev/null and b/robohash/sets/set4/003#03mouth/000#mouth0.png differ diff --git a/robohash/sets/set4/003#03mouth/001#mouth1.png b/robohash/sets/set4/003#03mouth/001#mouth1.png new file mode 100644 index 0000000..d9f3d32 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/001#mouth1.png differ diff --git a/robohash/sets/set4/003#03mouth/002#mouth2.png b/robohash/sets/set4/003#03mouth/002#mouth2.png new file mode 100644 index 0000000..5887851 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/002#mouth2.png differ diff --git a/robohash/sets/set4/003#03mouth/003#mouth3.png b/robohash/sets/set4/003#03mouth/003#mouth3.png new file mode 100644 index 0000000..949dc9e Binary files /dev/null and b/robohash/sets/set4/003#03mouth/003#mouth3.png differ diff --git a/robohash/sets/set4/003#03mouth/004#mouth4.png b/robohash/sets/set4/003#03mouth/004#mouth4.png new file mode 100644 index 0000000..eec85fa Binary files /dev/null and b/robohash/sets/set4/003#03mouth/004#mouth4.png differ diff --git a/robohash/sets/set4/003#03mouth/005#mouth5.png b/robohash/sets/set4/003#03mouth/005#mouth5.png new file mode 100644 index 0000000..bc9fae6 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/005#mouth5.png differ diff --git a/robohash/sets/set4/003#03mouth/006#mouth6.png b/robohash/sets/set4/003#03mouth/006#mouth6.png new file mode 100644 index 0000000..38bf8f1 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/006#mouth6.png differ diff --git a/robohash/sets/set4/003#03mouth/007#mouth7.png b/robohash/sets/set4/003#03mouth/007#mouth7.png new file mode 100644 index 0000000..1ff0642 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/007#mouth7.png differ diff --git a/robohash/sets/set4/003#03mouth/008#mouth8.png b/robohash/sets/set4/003#03mouth/008#mouth8.png new file mode 100644 index 0000000..3b14b13 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/008#mouth8.png differ diff --git a/robohash/sets/set4/003#03mouth/009#mouth9.png b/robohash/sets/set4/003#03mouth/009#mouth9.png new file mode 100644 index 0000000..3b95675 Binary files /dev/null and b/robohash/sets/set4/003#03mouth/009#mouth9.png differ diff --git a/robohash/sets/set4/004#04accessories/000#accessory0.png b/robohash/sets/set4/004#04accessories/000#accessory0.png new file mode 100644 index 0000000..241ae6b Binary files /dev/null and b/robohash/sets/set4/004#04accessories/000#accessory0.png differ diff --git a/robohash/sets/set4/004#04accessories/001#accessory1.png b/robohash/sets/set4/004#04accessories/001#accessory1.png new file mode 100644 index 0000000..8153667 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/001#accessory1.png differ diff --git a/robohash/sets/set4/004#04accessories/002#accessory2.png b/robohash/sets/set4/004#04accessories/002#accessory2.png new file mode 100644 index 0000000..4f04ffd Binary files /dev/null and b/robohash/sets/set4/004#04accessories/002#accessory2.png differ diff --git a/robohash/sets/set4/004#04accessories/003#accessory3.png b/robohash/sets/set4/004#04accessories/003#accessory3.png new file mode 100644 index 0000000..66e848d Binary files /dev/null and b/robohash/sets/set4/004#04accessories/003#accessory3.png differ diff --git a/robohash/sets/set4/004#04accessories/004#accessory4.png b/robohash/sets/set4/004#04accessories/004#accessory4.png new file mode 100644 index 0000000..895e121 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/004#accessory4.png differ diff --git a/robohash/sets/set4/004#04accessories/005#accessory5.png b/robohash/sets/set4/004#04accessories/005#accessory5.png new file mode 100644 index 0000000..eed0368 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/005#accessory5.png differ diff --git a/robohash/sets/set4/004#04accessories/006#accessory6.png b/robohash/sets/set4/004#04accessories/006#accessory6.png new file mode 100644 index 0000000..c28c064 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/006#accessory6.png differ diff --git a/robohash/sets/set4/004#04accessories/007#accessory7.png b/robohash/sets/set4/004#04accessories/007#accessory7.png new file mode 100644 index 0000000..76843da Binary files /dev/null and b/robohash/sets/set4/004#04accessories/007#accessory7.png differ diff --git a/robohash/sets/set4/004#04accessories/008#accessory8.png b/robohash/sets/set4/004#04accessories/008#accessory8.png new file mode 100644 index 0000000..7fe65ab Binary files /dev/null and b/robohash/sets/set4/004#04accessories/008#accessory8.png differ diff --git a/robohash/sets/set4/004#04accessories/009#accessory9.png b/robohash/sets/set4/004#04accessories/009#accessory9.png new file mode 100644 index 0000000..b452cb1 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/009#accessory9.png differ diff --git a/robohash/sets/set4/004#04accessories/010#accessory10.png b/robohash/sets/set4/004#04accessories/010#accessory10.png new file mode 100644 index 0000000..a99eaff Binary files /dev/null and b/robohash/sets/set4/004#04accessories/010#accessory10.png differ diff --git a/robohash/sets/set4/004#04accessories/011#accessory11.png b/robohash/sets/set4/004#04accessories/011#accessory11.png new file mode 100644 index 0000000..b4981c0 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/011#accessory11.png differ diff --git a/robohash/sets/set4/004#04accessories/012#accessory12.png b/robohash/sets/set4/004#04accessories/012#accessory12.png new file mode 100644 index 0000000..8c48e99 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/012#accessory12.png differ diff --git a/robohash/sets/set4/004#04accessories/013#accessory13.png b/robohash/sets/set4/004#04accessories/013#accessory13.png new file mode 100644 index 0000000..f2b0d94 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/013#accessory13.png differ diff --git a/robohash/sets/set4/004#04accessories/014#accessory14.png b/robohash/sets/set4/004#04accessories/014#accessory14.png new file mode 100644 index 0000000..a6245e5 Binary files /dev/null and b/robohash/sets/set4/004#04accessories/014#accessory14.png differ diff --git a/robohash/sets/set4/004#04accessories/015#accessory15.png b/robohash/sets/set4/004#04accessories/015#accessory15.png new file mode 100644 index 0000000..4bc109f Binary files /dev/null and b/robohash/sets/set4/004#04accessories/015#accessory15.png differ diff --git a/robohash/templates/root.html b/robohash/templates/root.html index f742f64..1fa8ec1 100644 --- a/robohash/templates/root.html +++ b/robohash/templates/root.html @@ -15,7 +15,7 @@ colin@robohash.org
- +That guy to your left there? He was specially generated from your IP address Just for you.
Try on your phone, and I bet you get someone different!
Keep scrolling down to see some more freshly-assembled RoboHashes.
- @@ -202,7 +202,7 @@ function submitform()By appending ?set=set2 to our Image's URLs, we are able to generate a whole slew of Random monsters. Here are 5 we picked out for you.
- +By appending ?set=set3 to our URLs, we get back to robots. New, suave, disembodied heads. That's sexy. Like a robot.
- +By appending ?set=set4 to our URLs, we can hydroponically grow beautiful kittens.
+ +Anytime you need a Robohash, just embed
<img src="https://robohash.org/YOUR-TEXT.png">
Want a JPG instead? Fine. PNG? Fine. Want it as a bitmap? I think you're nutty. But fine. Just change the URL to request in any format you want. Use ?ignoreext=false to make the bots care about extensions.
- +Due to Robot caching modules and CDN usage, our robots stay speedy, and only rarely go on murderous rampages. That's a Fact!
- +From destroying skyscrapers to nonobots, we've got you covered. Try appending ?size=200x200
Our robots like to travel. If you append ?bgset=bg1 (or bg2 or any) to your URL, our robots will add a background as part of the hash.
- +Robohash.org robots believe in Family, Warmth, and killing-all-humans. To that end, we provide this service for free.
- +RoboHash.org is here because Robots are funny, and because I needed the algorithm/art anyway for a Super-Awesome new forum I'm working on. If you use a specific set, or a list of them, like "?sets=1,3" , it'll probably stay the same as it is now. If you use "set=any", it'll include any new sets I happen to add, so existing hashes may change.
- + You should email me - - + colin@robohash.org
-
+
If the bandwidth gets crazy, I might add a [Robohash.org] banner to the bottom of the image. But it'd be super-tasteful.
-
Both traditional and new Stealthy (https) robots are available.
We've also conditioned our robots to accept commands either via params or directories-
For instance https://robohash.org/set_set3/bgset_bg1/3.14159?size=500x500
Finally, the Blueprints are available to build your own robotic factory.
@@ -528,12 +558,12 @@ function submitform() - - - - - + + + + +