|
| 1 | +# Configuration Options |
| 2 | + |
| 3 | +## Image Processing Options |
| 4 | + |
| 5 | +### `width` |
| 6 | +Limit the width of the image. Can be: |
| 7 | + |
| 8 | +- Integer (pixels) |
| 9 | +- Tailwind size string: "xs", "sm", "md", "lg", "screen-sm", "screen-md", "screen-lg", "screen-xl", "screen-2xl" |
| 10 | + |
| 11 | +```python |
| 12 | +Img(width=300) # Fixed width |
| 13 | +Img(width="md") # Responsive width |
| 14 | +``` |
| 15 | + |
| 16 | +### `ratio` |
| 17 | +The aspect ratio of the image. Can be: |
| 18 | + |
| 19 | +- Float (e.g. `4/5`) |
| 20 | +- String: "square", "video" (16/9), "video_vertical", "golden", "golden_vertical" |
| 21 | + |
| 22 | +```python |
| 23 | +Img(ratio="square") # 1:1 ratio |
| 24 | +Img(ratio=16/9) # Custom ratio |
| 25 | +``` |
| 26 | + |
| 27 | +### `crop` |
| 28 | +How to crop the image: |
| 29 | + |
| 30 | +- `True` (default): Crop from center (0.5, 0.5) |
| 31 | +- `False`: Don't crop (use CSS object-fit instead) |
| 32 | +- Tuple: (x%, y%) crop position |
| 33 | +- String: Position keywords like "tl", "tr", "bl", "br", "l", "r", "t", "b" |
| 34 | + |
| 35 | +```python |
| 36 | +Img(crop="tl") # Crop from top-left |
| 37 | +Img(crop=False) # No cropping |
| 38 | +``` |
| 39 | + |
| 40 | +### `quality` |
| 41 | +Image compression quality (default: 80) |
| 42 | + |
| 43 | +```python |
| 44 | +Img(quality=90) # Higher quality |
| 45 | +``` |
| 46 | + |
| 47 | +## Advanced Options |
| 48 | + |
| 49 | +### `sizes` |
| 50 | +Responsive sizes for different media queries: |
| 51 | + |
| 52 | +```python |
| 53 | +Img( |
| 54 | + width=300, |
| 55 | + sizes={ |
| 56 | + "print": {"width": 450, "quality": 90}, |
| 57 | + 800: 100 # Max-width 800px |
| 58 | + } |
| 59 | +) |
| 60 | +``` |
| 61 | + |
| 62 | +### `format` |
| 63 | +`srcset` image format (default: "webp"): |
| 64 | + |
| 65 | +- "webp" (recommended) |
| 66 | +- "avif" (memory intensive) |
| 67 | +- "jpeg" |
| 68 | + |
| 69 | +```python |
| 70 | +Img(format="avif") # Use AVIF format |
| 71 | +``` |
| 72 | + |
| 73 | +### `focal_window` |
| 74 | +Zoom area specified as (x1%, y1%, x2%, y2%): |
| 75 | + |
| 76 | +```python |
| 77 | +Img(focal_window=(25, 25, 75, 75)) # Zoom center 50% of image |
| 78 | +``` |
| 79 | + |
| 80 | +### `densities` |
| 81 | +Higher density versions to generate (default: `[2]`): |
| 82 | + |
| 83 | +```python |
| 84 | +Img(densities=[1.5, 2, 3]) # Generate 1.5x, 2x and 3x versions |
| 85 | +``` |
0 commit comments