fix
This commit is contained in:
1 parent
d56ddc9342
commit
fa0e929a1a
9 files changed
+267
-9
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from utils.entity.RouMan import comicEntity
|
from utils.entity.RouMan import comicEntity
|
||||||
|
from utils.comic.PathStr import pathStr
|
||||||
#from utils.entity.JMTI import comicEntity
|
#from utils.entity.JMTI import comicEntity
|
||||||
|
|
||||||
def comics():
|
def comics():
|
||||||
@@ -7,6 +8,7 @@ def comics():
|
|||||||
comicEntity.downladsComcis("https://rm01.xyz/books?&page="+str(x))
|
comicEntity.downladsComcis("https://rm01.xyz/books?&page="+str(x))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# pathStr.setComicMainPath("JM")
|
||||||
comics()
|
comics()
|
||||||
# os.environ["http_proxy"] = "http://127.0.0.1:7890"
|
# os.environ["http_proxy"] = "http://127.0.0.1:7890"
|
||||||
# os.environ["https_proxy"] = "http://127.0.0.1:7890"
|
# os.environ["https_proxy"] = "http://127.0.0.1:7890"
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class comicInfo():
|
|||||||
str_web = None
|
str_web = None
|
||||||
str_list_img = None
|
str_list_img = None
|
||||||
str_files_img = None
|
str_files_img = None
|
||||||
|
str_value1 = None
|
||||||
|
|
||||||
chapter_node = None
|
chapter_node = None
|
||||||
comicName_node = None
|
comicName_node = None
|
||||||
@@ -132,6 +133,14 @@ class comicInfo():
|
|||||||
def setChapterListImg(cls,value):
|
def setChapterListImg(cls,value):
|
||||||
cls.str_list_img=value
|
cls.str_list_img=value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setValue1(cls,value):
|
||||||
|
cls.str_value1 = value
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def getValue1(cls):
|
||||||
|
return cls.str_value1
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getChapterListImg(cls):
|
def getChapterListImg(cls):
|
||||||
return cls.str_list_img
|
return cls.str_list_img
|
||||||
@@ -252,7 +261,7 @@ class comicInfo():
|
|||||||
@classmethod
|
@classmethod
|
||||||
def getDirCBZComic(cls):
|
def getDirCBZComic(cls):
|
||||||
if not cls.str_comicName == None:
|
if not cls.str_comicName == None:
|
||||||
return os.path.join(pathStr.base_CBZ, cls.str_comicName)
|
return os.path.join(pathStr.base_cbz, cls.str_comicName)
|
||||||
else:
|
else:
|
||||||
print("comicName不存在,退出中")
|
print("comicName不存在,退出中")
|
||||||
exit()
|
exit()
|
||||||
@@ -260,7 +269,7 @@ class comicInfo():
|
|||||||
@classmethod
|
@classmethod
|
||||||
def getDirCBZComicChapter(cls):
|
def getDirCBZComicChapter(cls):
|
||||||
if not cls.str_comicName == None and not cls.str_chapter == None:
|
if not cls.str_comicName == None and not cls.str_chapter == None:
|
||||||
return os.path.join(pathStr.base_CBZ,cls.str_comicName,cls.str_chapter)
|
return os.path.join(pathStr.base_cbz,cls.str_comicName,cls.str_chapter)
|
||||||
else:
|
else:
|
||||||
print("comicName不存在,退出中")
|
print("comicName不存在,退出中")
|
||||||
exit()
|
exit()
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
import os,datetime
|
import os,datetime
|
||||||
from time import strftime
|
from time import strftime
|
||||||
class pathStr:
|
class pathStr:
|
||||||
|
comic_url_main = None
|
||||||
#base_comic_out = "COMICOUT"
|
#base_comic_out = "COMICOUT"
|
||||||
#base_comic_out = os.path.join("/mnt", "bigTComics","JM")
|
#base_comic_out = os.path.join("/mnt", "bigTComics","JM")
|
||||||
|
if comic_url_main != None:
|
||||||
|
base_comic_out = os.path.join("/mnt", "bigTComics", comic_url_main)
|
||||||
base_comic_out = os.path.join("/mnt", "bigTComics")
|
base_comic_out = os.path.join("/mnt", "bigTComics")
|
||||||
base_CBZ = os.path.join(base_comic_out,"CBZ")
|
base_cbz = os.path.join(base_comic_out,"CBZ")
|
||||||
base_comic_img = os.path.join(base_comic_out,"outputComic")
|
base_comic_img = os.path.join(base_comic_out,"outputComic")
|
||||||
base_conf_path = os.path.join(base_comic_out,".conf")
|
base_conf_path = os.path.join(base_comic_out,".conf")
|
||||||
base_html_cache = os.path.join(base_comic_out,"html_cache")
|
base_html_cache = os.path.join(base_comic_out,"html_cache")
|
||||||
base_html_chapter = os.path.join(base_comic_out,"html_updated")
|
base_html_chapter = os.path.join(base_comic_out,"html_updated")
|
||||||
base_comic_update = os.path.join(base_conf_path,"comic_update")
|
base_comic_update = os.path.join(base_conf_path,"comic_update")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setComicMainPath(cls,value):
|
||||||
|
cls.comic_url_main = value
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def base_html_week(cls):
|
def base_html_week(cls):
|
||||||
date_path = cls.getDatePath()
|
date_path = cls.getDatePath()
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import json
|
||||||
|
from utils.HtmlUtils import htmlUtils
|
||||||
|
from utils.comic.ComicInfo import comicInfo
|
||||||
|
from utils.downloader import download_images
|
||||||
|
from utils.entity.BaseComicEntity import baseComic
|
||||||
|
|
||||||
|
class comicEntity:
|
||||||
|
@classmethod
|
||||||
|
def baseComicData(cls,url,update=False):
|
||||||
|
data = htmlUtils.xpathData('//script[@id="__NEXT_DATA__"]/text()',url=url,update=update)
|
||||||
|
data = json.loads(data[0])
|
||||||
|
data = data.get("props")
|
||||||
|
x = data.get("pageProps")
|
||||||
|
return x
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def downladsComcis(cls,url):
|
||||||
|
#漫画名
|
||||||
|
x = cls.baseComicData(url)
|
||||||
|
books = x.get("books")
|
||||||
|
len_books = len(books)
|
||||||
|
base_url = comicInfo.getBaseUrl(url)
|
||||||
|
for x in range(0, len_books):
|
||||||
|
book = books[x]
|
||||||
|
book_id = book.get("id")
|
||||||
|
book_name = book.get("name")
|
||||||
|
updated = book.get("updatedAt")
|
||||||
|
comic_href = base_url+"/books/"+book_id
|
||||||
|
href = baseComic.downladsComcis(book_name=book_name,comic_href=comic_href,updated=updated)
|
||||||
|
cls.oneComic(href)
|
||||||
|
comicInfo.updateComicDate()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def oneComic(cls,c_url,sleep=None):
|
||||||
|
#漫画名
|
||||||
|
title = htmlUtils.xpathData('//div[@class="gb-inside-container"]/h1[contains(@class,"gb-headline-text")]/text()',url=c_url,update=True)
|
||||||
|
#别名
|
||||||
|
#alias = htmlUtils.xpathData('//span[contains(@class,"bookid_alias")]/text()',num=1)
|
||||||
|
#icon = htmlUtils.xpathData('//div[contains(@class,"gb-container")]/div[@class="gb-inside-container"]/img[contains(@class,"dynamic-featured-image")]/@src')
|
||||||
|
icon = htmlUtils.xpathData('//noscript/img[contains(@class,"dynamic-featured-image")]/@src')
|
||||||
|
author = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div[@class="author-content"]/a/text()')
|
||||||
|
tags = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div[@class="genres-content"]/a/text()')
|
||||||
|
dep = htmlUtils.xpathData('//div[@class="gb-inside-container"]/div[@class="descrip_manga_info"]//p/text()')
|
||||||
|
update_date = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapter"]//span[@class="chapter-release-date"]/i/text()')
|
||||||
|
c_url = str(c_url).replace("manga","chapterlist")+"#"
|
||||||
|
chapters = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapter"]/text()',not_eq=' ',url=c_url)
|
||||||
|
chapter_href = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapter"]/@href',url=c_url)
|
||||||
|
c_url = c_url+"#"
|
||||||
|
chapters = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapter"]/text()',not_eq=' ',url=c_url)
|
||||||
|
chapter_href = htmlUtils.xpathData('//div[@class="chapter-content-listing"]//a[@class="wp-manga-chapter"]/@href',url=c_url)
|
||||||
|
|
||||||
|
baseComic.oneComic(url=c_url,title=title,author=author,
|
||||||
|
icon=icon,tags=tags,dep=dep,chapters=chapters,chapter_href=chapter_href,
|
||||||
|
alias=None)
|
||||||
@@ -29,6 +29,7 @@ class baseComic:
|
|||||||
return comic_href
|
return comic_href
|
||||||
else:
|
else:
|
||||||
ntfy.sendMsg(f"{book_name} 已是最新")
|
ntfy.sendMsg(f"{book_name} 已是最新")
|
||||||
|
return None
|
||||||
|
|
||||||
#print(books)
|
#print(books)
|
||||||
#for comicHref in comicsHref:
|
#for comicHref in comicsHref:
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import json
|
||||||
|
import re
|
||||||
|
from utils.HtmlUtils import htmlUtils
|
||||||
|
from utils.comic.ComicInfo import comicInfo
|
||||||
|
from utils.downloader import download_images
|
||||||
|
from utils.entity.BaseComicEntity import baseComic
|
||||||
|
|
||||||
|
class comicEntity:
|
||||||
|
@classmethod
|
||||||
|
def baseComicData(cls,url,update=False):
|
||||||
|
data = htmlUtils.xpathData('//script[@id="__NEXT_DATA__"]/text()',url=url,update=update)
|
||||||
|
data = json.loads(data[0])
|
||||||
|
data = data.get("props")
|
||||||
|
x = data.get("pageProps")
|
||||||
|
return x
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def downladsComcis(cls,url):
|
||||||
|
#漫画名
|
||||||
|
x = cls.baseComicData(url)
|
||||||
|
books = x.get("books")
|
||||||
|
len_books = len(books)
|
||||||
|
base_url = comicInfo.getBaseUrl(url)
|
||||||
|
for x in range(0, len_books):
|
||||||
|
book = books[x]
|
||||||
|
book_id = book.get("id")
|
||||||
|
book_name = book.get("name")
|
||||||
|
updated = book.get("updatedAt")
|
||||||
|
comic_href = base_url+"/books/"+book_id
|
||||||
|
href = baseComic.downladsComcis(book_name=book_name,comic_href=comic_href,updated=updated)
|
||||||
|
cls.oneComic(href)
|
||||||
|
comicInfo.updateComicDate()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def oneComic(cls,c_url,sleep=None):
|
||||||
|
nums = htmlUtils.xpathData("//div[@class='row']/div[6]/div[1]/div[1]/ul[contains(@class,'btn-toolbar')]/a",url=c_url,update=True)
|
||||||
|
book_name = htmlUtils.xpathData("//div[@itemprop='name']/h1[@id='book-name']/text()",num=0)
|
||||||
|
title = re.sub(r'[\\\/\|\(\)\~\?\.\:\:\-\*\<\>]', '', book_name)
|
||||||
|
tags = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='tags']/a[@class='btn btn-sm btn-primary']/text()")
|
||||||
|
author = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='author']/a[@class='btn btn-sm btn-primary']/text()")
|
||||||
|
book_msg = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='p-t-5 p-b-5']/text()")
|
||||||
|
jmid = book_msg[0]
|
||||||
|
dep = str(book_msg[1]).replace("叙述:","")
|
||||||
|
icon = htmlUtils.xpathData("//div[@class='row']//div[@class='thumb-overlay']/img/@src",num=0)
|
||||||
|
|
||||||
|
referer = re.search(r'(https://\w+\.\w+)/', c_url).group(1)
|
||||||
|
if nums:
|
||||||
|
list_chapter_name = []
|
||||||
|
list_chapter_href = []
|
||||||
|
list_chapter_update = []
|
||||||
|
cls.count_chapter = 0
|
||||||
|
|
||||||
|
for i in nums:
|
||||||
|
photo_name_list = i.xpath("li/text()")[0].split()
|
||||||
|
photo_date = i.xpath("li/span/text()")[0].split()
|
||||||
|
#print(re.findall(r'[\u4E00-\u9FA5]+.*?', i.xpath("li/text()")[0]))
|
||||||
|
try:
|
||||||
|
if re.findall(r'[\u4E00-\u9FA5]', photo_name_list[2]):
|
||||||
|
photo_name=re.sub(r'\s','',photo_name_list[0])+' '+photo_name_list[2]
|
||||||
|
else:photo_name=re.sub(r'\s','',photo_name_list[0])
|
||||||
|
except Exception as e:
|
||||||
|
photo_name = re.sub(r'\s', '', photo_name_list[0])
|
||||||
|
photo_name = re.sub(r'[\\\/\|\(\)\~\?\.\:\:\-\*\<\>\-]', '',photo_name)
|
||||||
|
#print(photo_name)
|
||||||
|
photoid=i.attrib['data-album']
|
||||||
|
cls.aid = photoid
|
||||||
|
comicInfo.setValue1(cls.aid)
|
||||||
|
list_chapter_name.append(photo_name)
|
||||||
|
list_chapter_href.append(referer+i.attrib['href'])
|
||||||
|
list_chapter_update.append(photo_date[0])
|
||||||
|
|
||||||
|
baseComic.oneComic(url=c_url,title=title,author=author,
|
||||||
|
icon=icon,tags=tags,dep=dep,chapters=list_chapter_name,chapter_href=list_chapter_href,
|
||||||
|
alias=None)
|
||||||
@@ -5,6 +5,7 @@ from utils.HtmlUtils import htmlUtils
|
|||||||
from utils.ImageUtils import imageUtils
|
from utils.ImageUtils import imageUtils
|
||||||
from utils.comic.ComicInfo import comicInfo
|
from utils.comic.ComicInfo import comicInfo
|
||||||
from utils.CBZUtils import CBZUtils
|
from utils.CBZUtils import CBZUtils
|
||||||
|
from utils.CBZUtils import verUtils
|
||||||
from utils.downloader import download_images
|
from utils.downloader import download_images
|
||||||
from utils.Ntfy import ntfy
|
from utils.Ntfy import ntfy
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -50,7 +51,7 @@ class comicEntity:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def oneComic(cls,c_url,sleep=None):
|
def oneComic(cls,c_url,sleep=None):
|
||||||
nums = htmlUtils.xpathData("//div[@class='row']/div[6]/div[1]/div[1]/ul[contains(@class,'btn-toolbar')]/a",url=c_url,update=True)
|
nums = htmlUtils.xpathData("//div[@class='row']/div[6]/div[1]/div[1]/ul[contains(@class,'btn-toolbar')]/a",url=c_url,update=True)
|
||||||
book_name = htmlUtils.xpathData("//div[@itemprop='name']/h1[@id='book-name']/text()")
|
book_name = htmlUtils.xpathData("//div[@itemprop='name']/h1[@id='book-name']/text()",num=0)
|
||||||
book_name = re.sub(r'[\\\/\|\(\)\~\?\.\:\:\-\*\<\>]', '', book_name)
|
book_name = re.sub(r'[\\\/\|\(\)\~\?\.\:\:\-\*\<\>]', '', book_name)
|
||||||
tags = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='tags']/a[@class='btn btn-sm btn-primary']/text()")
|
tags = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='tags']/a[@class='btn btn-sm btn-primary']/text()")
|
||||||
author = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='author']/a[@class='btn btn-sm btn-primary']/text()")
|
author = htmlUtils.xpathData("//div[@class='row']/div[@class='col-lg-7']/div[1]/div[@class='tag-block']/span[@data-type='author']/a[@class='btn btn-sm btn-primary']/text()")
|
||||||
@@ -65,7 +66,6 @@ class comicEntity:
|
|||||||
comicInfo.setAuthor(author)
|
comicInfo.setAuthor(author)
|
||||||
comicInfo.setDep(dep)
|
comicInfo.setDep(dep)
|
||||||
comicInfo.setTags(tags)
|
comicInfo.setTags(tags)
|
||||||
comicInfo.setTag(tags)
|
|
||||||
comicInfo.setCBS("韩漫")
|
comicInfo.setCBS("韩漫")
|
||||||
comicInfo.setLang("zh")
|
comicInfo.setLang("zh")
|
||||||
albumid = re.search(r'/album/(\d+)', c_url).group(1)
|
albumid = re.search(r'/album/(\d+)', c_url).group(1)
|
||||||
|
|||||||
@@ -25,10 +25,13 @@ class comicEntity:
|
|||||||
book_id = book.get("id")
|
book_id = book.get("id")
|
||||||
book_name = book.get("name")
|
book_name = book.get("name")
|
||||||
updated = book.get("updatedAt")
|
updated = book.get("updatedAt")
|
||||||
comic_href = base_url+"/books/"+book_id
|
comic_href = base_url+"/books/"+book_id
|
||||||
|
comicInfo.setUpdateAt(updated)
|
||||||
|
comicInfo.setComicName(book_name)
|
||||||
href = baseComic.downladsComcis(book_name=book_name,comic_href=comic_href,updated=updated)
|
href = baseComic.downladsComcis(book_name=book_name,comic_href=comic_href,updated=updated)
|
||||||
cls.oneComic(href)
|
if href != None:
|
||||||
comicInfo.updateComicDate()
|
cls.oneComic(href)
|
||||||
|
comicInfo.updateComicDate()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def oneComic(cls,c_url,sleep=None):
|
def oneComic(cls,c_url,sleep=None):
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from utils.HtmlUtils import htmlUtils
|
||||||
|
from utils.ImageUtils import imageUtils
|
||||||
|
from utils.comic.ComicInfo import comicInfo
|
||||||
|
from utils.Ntfy import ntfy
|
||||||
|
|
||||||
|
class comicCommon:
|
||||||
|
@classmethod
|
||||||
|
def comicChapterDownload(cls,chapter_url):
|
||||||
|
chapter_url = chapter_url+"?shunt=2"
|
||||||
|
img_list =htmlUtils.xpathData("//div[@class='panel-body']/div/div[contains(@class,'center scramble-page')]/img/@data-original",url=chapter_url,update=True)
|
||||||
|
pages_imgs =htmlUtils.xpathData("//div[@class='center scramble-page']/@id",url=chapter_url)
|
||||||
|
comicInfo.setPages(pages_imgs)
|
||||||
|
comicInfo.writeComicInfoXML(comicInfo.str_chapter)
|
||||||
|
#print("img_list:",len(img_list))
|
||||||
|
list_img = []
|
||||||
|
list_file_name = []
|
||||||
|
for i in img_list:
|
||||||
|
img_url= i
|
||||||
|
img_name = os.path.basename(img_url).split('.')[0]
|
||||||
|
aid = int(comicInfo.getValue1())
|
||||||
|
if aid > 220980:
|
||||||
|
#if is_scramble:
|
||||||
|
img_name = "scramble="+str(cls.get_scramble_num(aid,img_name))+"_"+img_name
|
||||||
|
#path_img = "%s\\%s.jpg" % (cls.aid, img_name)
|
||||||
|
path_img = "%s.jpg" % (img_name)
|
||||||
|
list_img.append(img_url)
|
||||||
|
list_file_name.append(path_img)
|
||||||
|
comicInfo.comicChapterDownload(list_img,list_file_name)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_md5(cls,num):
|
||||||
|
result1 = hashlib.md5(num.encode()).hexdigest()
|
||||||
|
print('get_md5-', result1)
|
||||||
|
return result1
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_scramble_num(cls,e, t):
|
||||||
|
#print(type(e),e, type(t),t)
|
||||||
|
a = 10
|
||||||
|
try:
|
||||||
|
num_dict = {}
|
||||||
|
for i in range(10):
|
||||||
|
num_dict[i] = i * 2 + 2
|
||||||
|
if (int(e) >= 268850):
|
||||||
|
n = str(e) + t;
|
||||||
|
# switch(n=(n = (n = md5(n)).substr(-1)), n %= 10) {
|
||||||
|
#print("n=",n)
|
||||||
|
tmp = ord(cls.get_md5(n)[-1])
|
||||||
|
result = num_dict[tmp % 10]
|
||||||
|
a = result
|
||||||
|
return a
|
||||||
|
except Exception as e:
|
||||||
|
print(e.__traceback__.tb_lineno,e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def encode_scramble_image(cls,imgpath):
|
||||||
|
image = Image.open(imgpath)
|
||||||
|
w, h = image.size
|
||||||
|
#image.show()
|
||||||
|
file_str = str(imgpath).split("=")
|
||||||
|
#10_29.jpg
|
||||||
|
base_dir = file_str[0].replace("scramble","")
|
||||||
|
base_name = file_str[-1]
|
||||||
|
base_fn = base_name.split("_")
|
||||||
|
save_name = base_fn[1]
|
||||||
|
save_name_delesu = save_name.split(".")[0]
|
||||||
|
blocks = int(base_fn[0])
|
||||||
|
img_type = os.path.basename(imgpath).split('.')[-1]
|
||||||
|
save_path = os.path.join(os.path.dirname(imgpath),save_name_delesu+"."+img_type)
|
||||||
|
# print(type(aid),type(img_name))
|
||||||
|
if blocks:
|
||||||
|
s = blocks # 随机值
|
||||||
|
# print(s)
|
||||||
|
l = h % s # 切割最后多余的值
|
||||||
|
box_list = []
|
||||||
|
hz = 0
|
||||||
|
for i in range(s):
|
||||||
|
c = math.floor(h / s)
|
||||||
|
g = i * c
|
||||||
|
hz += c
|
||||||
|
h2 = h - c * (i + 1) - l
|
||||||
|
if i == 0:
|
||||||
|
c += l;hz += l
|
||||||
|
else:
|
||||||
|
g += l
|
||||||
|
box_list.append((0, h2, w, h - g))
|
||||||
|
|
||||||
|
# print(box_list,len(box_list))
|
||||||
|
item_width = w
|
||||||
|
# box_list.reverse() #还原切图可以倒序列表
|
||||||
|
# print(box_list, len(box_list))
|
||||||
|
newh = 0
|
||||||
|
image_list = [image.crop(box) for box in box_list]
|
||||||
|
# print(box_list)
|
||||||
|
newimage = Image.new("RGB", (w, h))
|
||||||
|
for image in image_list:
|
||||||
|
# image.show()
|
||||||
|
b_w, b_h = image.size
|
||||||
|
newimage.paste(image, (0, newh))
|
||||||
|
|
||||||
|
newh += b_h
|
||||||
|
newimage.save(save_path)
|
||||||
|
if os.path.exists(imgpath):
|
||||||
|
os.remove(imgpath)
|
||||||
Reference in new issue
Block a user