Kilogram imaging : use N Pieces of pictures put together to make a picture .undefined Realization principle : First, the image to be imaged is converted into mosaic image , Then replace the corresponding color block with the corresponding color image from the library .undefined Image processing in the gallery : Mark the mixed colors of each picture in the gallery , Used to replace the target color block , And record the characteristics of each image for imaging , Increase image quality .
0, origin
Delaware
Part of the picture
Hero alliance - Microblogging
I saw this message when I was blogging a long time ago , I was shocked by him , The picture is made up of LOL A combination of nearly a thousand skin pictures ( Is this using ps It's done , It's still spelled one by one , It shouldn't be possible ), Just yesterday, I suddenly remembered this thing , I decided to do one, too , Even if the action is taken . I found this article , Look at the composition of the picture , Decide to get all the skin pictures first ! Then it began again Reptiles !
Running environment :Python3.6.5 , pycharm-2018-1-2 , win10
What are you waiting for , Look down
1. Reptilian thinking
Skin image source
obtain URL
URLS
selenium
Library to simulate people using the browser to get all the pictures , But this will cause the speed of crawling pictures to be greatly reduced , It can only be used as a bad policy ( In the process, I learned octopus , It is found that the principle is similar to selenium, It's the Sims who control the browser , Speed is also not allowed to look directly , Although it can climb close 98% Website ), When the blogger's ability is limited, he chose the journey of finding rules !undefined If you have a good way to solve this problem , You can put forward... In the comments section , Thank you very much. !Network
Look at the preview, You can get all hero numbers , And the test found that ! such as Ashe Aishi's first skin corresponding number should be 22001, therefore URL Namely , The test found that it was indeed successful !
preview
2, The code framework
3, Complete code
import requests import re import os # # # # # # # # # # # # # # # title: obtain LOL Hero skin image # # author: Simple books Wayne_Dream # # date:2018-7-5 # # Reprint please indicate the source !!! # # # # # # # # # # # # # # # def getHero_data(): try: headers = { 'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' } url = 'http://lol.qq.com/biz/hero/champion.js' r = requests.get(url, headers=headers) r.raise_for_status() r.encoding = r.apparent_encoding text = r.text hero_id = re.findall(r'"id":"(.*?)","key"', text) hero_num = re.findall(r'"key":"(.*?)"', text) return hero_id, hero_num except: return ' Oh my god , Failed to get hero code !' def getUrl(hero_num): part1 = 'https://game.gtimg.cn/images/daoju/app/lol/medium/2-' part3 = '-9.jpg' skin_num = [] Url_list = [] for i in range(1, 21): i = str(i) if len(i) == 1: i = '00'+i elif len(i) == 2: i = '0'+i else: continue skin_num.append(i) for hn in hero_num: for sn in skin_num: part2 = hn + sn url = part1 + part2 + part3 Url_list.append(url) print(' picture URL To be successful ') return Url_list def PicName(hero_id, path): pic_name_list = [] for id in hero_id: for i in range(1, 21): pic_name = path + id + str(i) + '.jpg' pic_name_list.append(pic_name) return pic_name_list def DownloadPic(pic_name_list, Url_list): count = 0 n = len(Url_list) try: for i in range(n): headers = { 'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' } res = requests.get(Url_list[i], headers=headers).content if len(res) < 100: count += 1 print('\r Current progress :{:.2f}%'.format(100*(count/n)), end='') else: with open(pic_name_list[i], "wb") as f: f.write(res) count += 1 print('\r Current progress :{:.2f}%'.format(100*(count/n)), end='') except: return ' Oh my god , Failed to get picture !' if __name__ == '__main__': print('author: Simple books Wayne_Dream:') print('https://www.jianshu.com/u/6dd4484b4741') input(' Please enter any character to start crawling :') if os.path.exists('D:\LOLimg_wayne\\') == False: path = r'D:\LOLimg_wayne\\' os.mkdir(path) hero_id, hero_num = getHero_data() Url_list = getUrl(hero_num) pic_name_list = PicName(hero_id, path) print(' Downloading pictures , One moment please ...') print(' stay ' + path + ' Check out ...') DownloadPic(pic_name_list, Url_list) print(' The picture has been downloaded. ') else: path = r'D:\LOLimg_wayne\\' hero_id, hero_num = getHero_data() Url_list = getUrl(hero_num) pic_name_list = PicName(hero_id, path) print(' Downloading pictures , One moment please ...') print(' stay ' + path + ' Check out ...') DownloadPic(pic_name_list, Url_list) print(' The picture has been downloaded. ')
The code is ugly , If you don't understand something, you can put it forward in the comment area , I'll get back to you in seconds !/ Serious face
Okay , So far, we have finished LOL Whole skin acquisition , The next most interesting step , Kilogram imaging !( At the end of the article, there is the address of Baidu online disk of the skin atlas I climbed to )
4, In the initial stage, we first use a foreign synthesis software
Software download address
Windows Please select this
After opening, the interface is like this .
The first step is to create a gallery
Take the first step
1.1
1.2
Wait a moment
Choose the second step create photo mosaic
2.1
2.2
2.3
2.4
2.5, Pop up a warning point to confirm
design sketch
Local
Share how to use... When you have time python Realize the function of this software …………
If you find something wrong or don't understand , In the comments section , Let's talk !\
If the article helps you , give the thumbs-up + Focus on , Your support is my greatest motivation