|
|
@@ -148,8 +148,8 @@ class ImgsWithSizesRenderer(CustomAndBlockquoteLanguageRenderer): |
|
|
|
return src_size |
|
|
|
|
|
|
|
image = Image.open(full_path) |
|
|
|
image.thumbnail((width, height)) |
|
|
|
image.save(full_path_size) |
|
|
|
image.thumbnail((width, height), resample=Image.LANCZOS) |
|
|
|
image.save(full_path_size, icc_profile=image.info.get("icc_profile")) |
|
|
|
return src_size |
|
|
|
|
|
|
|
def _generate_webp(self, src): |
|
|
@@ -158,8 +158,23 @@ class ImgsWithSizesRenderer(CustomAndBlockquoteLanguageRenderer): |
|
|
|
full_path_webp = STATIC / Path(src_webp[1:]) |
|
|
|
if full_path_webp.exists() or "/2023/" not in src: |
|
|
|
return src_webp |
|
|
|
command = ["cwebp", "-q", "80", full_path, "-o", full_path_webp] |
|
|
|
subprocess.check_output(command, stderr=subprocess.STDOUT) |
|
|
|
|
|
|
|
image = Image.open(full_path) |
|
|
|
image.save( |
|
|
|
full_path_webp, format="webp", icc_profile=image.info.get("icc_profile") |
|
|
|
) |
|
|
|
# command = [ |
|
|
|
# "cwebp", |
|
|
|
# "-q", |
|
|
|
# "80", |
|
|
|
# full_path, |
|
|
|
# "-o", |
|
|
|
# full_path_webp, |
|
|
|
# "-metadata", |
|
|
|
# "icc", |
|
|
|
# ] |
|
|
|
# subprocess.check_output(command, stderr=subprocess.STDOUT) |
|
|
|
|
|
|
|
return src_webp |
|
|
|
|
|
|
|
def image(self, src, alt="", title=None): |