lektor_ng.imagetools

src/lektor_ng/imagetools/__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from __future__ import annotations

from pathlib import Path

from ..utils import deprecated
from .exif import read_exif
from .image_info import get_image_info
from .thumbnail import (
    Thumbnail,
    ThumbnailMode,
    compute_dimensions,
    make_image_thumbnail,
)

__all__ = [
    "Thumbnail",
    "ThumbnailMode",
    "compute_dimensions",
    "get_image_info",
    "get_quality",
    "make_image_thumbnail",
    "read_exif",
]


@deprecated(version="3.4.0")
def get_quality(source_filename: str | Path) -> int:
    """Get the effective default thumbnail _quality_.

    This is the ImageMagick "quality" that is used, by default, when generating
    thumbnails.

    """
    if get_image_info(source_filename).format == "png":
        return 75
    return 85