Thumb in initial image format
This commit is contained in:
parent
185120b575
commit
2190c06edd
3 changed files with 7 additions and 4 deletions
|
@ -8,7 +8,7 @@ Changes
|
||||||
- Swipe support
|
- Swipe support
|
||||||
- More space for images
|
- More space for images
|
||||||
- Restructure repository
|
- Restructure repository
|
||||||
- Use JPEG instead of PNG for thumbnails
|
- Use initial format instead of PNG for thumbnails
|
||||||
|
|
||||||
1.0.3 (*2021-07-13*)
|
1.0.3 (*2021-07-13*)
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -43,7 +43,7 @@ def copy_images_files(app: Sphinx, env: BuildEnvironment) -> None:
|
||||||
thumbsize = basename.split('-')[-1].split('x')
|
thumbsize = basename.split('-')[-1].split('x')
|
||||||
thumbsize = [int(size) for size in thumbsize]
|
thumbsize = [int(size) for size in thumbsize]
|
||||||
original = '.'.join(basename.split('.')[:-1]) + ext
|
original = '.'.join(basename.split('.')[:-1]) + ext
|
||||||
dest = basename + '.jpg'
|
dest = basename + ext
|
||||||
ensuredir(os.path.dirname(dest))
|
ensuredir(os.path.dirname(dest))
|
||||||
|
|
||||||
with Image.open(original) as im:
|
with Image.open(original) as im:
|
||||||
|
@ -68,7 +68,10 @@ def copy_images_files(app: Sphinx, env: BuildEnvironment) -> None:
|
||||||
(im.size[1]+thumbsize[0]*im.size[1]/thumbsize[0])//2,
|
(im.size[1]+thumbsize[0]*im.size[1]/thumbsize[0])//2,
|
||||||
))
|
))
|
||||||
|
|
||||||
out.save(dest, "JPEG", quality=90)
|
if ext.lower() in ("jpg", "jpeg"):
|
||||||
|
out.save(dest, "JPEG", quality=90)
|
||||||
|
else:
|
||||||
|
out.save(dest)
|
||||||
|
|
||||||
|
|
||||||
def install_static_files(app: Sphinx, env: BuildEnvironment) -> None:
|
def install_static_files(app: Sphinx, env: BuildEnvironment) -> None:
|
||||||
|
|
|
@ -87,7 +87,7 @@ class GalleriaCollector(EnvironmentCollector):
|
||||||
basename, ext = os.path.splitext(image_path)
|
basename, ext = os.path.splitext(image_path)
|
||||||
thumb_path = basename + ".thumb-" + thumbsize + ext
|
thumb_path = basename + ".thumb-" + thumbsize + ext
|
||||||
thumb_path_cropped = basename + ".thumb-" + thumbsize
|
thumb_path_cropped = basename + ".thumb-" + thumbsize
|
||||||
thumb_path_cropped += '.jpg'
|
thumb_path_cropped += ext
|
||||||
if ext.lower() in ('.svg', '.svgz'):
|
if ext.lower() in ('.svg', '.svgz'):
|
||||||
thumb_path_cropped = image_path
|
thumb_path_cropped = image_path
|
||||||
thumb_path = image_path
|
thumb_path = image_path
|
||||||
|
|
Loading…
Reference in a new issue