解决句柄占用问题。
This commit is contained in:
@@ -150,12 +150,11 @@ def download_image(img_url, folder_path, img_index, max_retries=3):
|
||||
time.sleep(2 * (attempt + 1))
|
||||
continue
|
||||
|
||||
img = Image.open(BytesIO(response.content)).convert('RGB')
|
||||
img_name = f"{img_index:03d}.jpg"
|
||||
img_path = os.path.join(folder_path, img_name)
|
||||
|
||||
img.save(img_path, 'JPEG', quality=95)
|
||||
logger.info(f"已下载并转换为JPG: {img_path}")
|
||||
with Image.open(BytesIO(response.content)).convert('RGB') as img:
|
||||
img_name = f"{img_index:03d}.jpg"
|
||||
img_path = os.path.join(folder_path, img_name)
|
||||
img.save(img_path, 'JPEG', quality=95)
|
||||
logger.info(f"已下载并转换为JPG: {img_path}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user