zimscraperlib.image.conversion
Functions:
-
convert_image–convert an image file from one format to another
-
convert_svg2png–Convert a SVG to a PNG
-
create_favicon–generate a squared favicon from a source image
convert_image
convert an image file from one format to another params: Image.save() parameters. Depends on dest format. params can include the following keys: - fmt: specify the dest format (otherwise guessed from extension) ex: JPEG, PNG, BMP (and other PIL formats) - colorspace: convert to this colorspace. Otherwise not converted unless target format has no halpha channel while source had. In this case converted to RGB. ex: RGB, ARGB, CMYK (and other PIL colorspaces)
Source code in src/zimscraperlib/image/conversion.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
convert_svg2png
convert_svg2png(
src: str | Path | BytesIO,
dst: Path | BytesIO,
width: int | None = None,
height: int | None = None,
)
Convert a SVG to a PNG
Output width and height might be specified if resize is needed. PNG background is transparent.
Source code in src/zimscraperlib/image/conversion.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
create_favicon
generate a squared favicon from a source image
Source code in src/zimscraperlib/image/conversion.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |