-
v0.3.1 Stable
released this
2025-11-21 18:04:50 +01:00 | 0 commits to main since this releaseSummary
There was a bug when passing a directory as the
source_pathto theWebImageobject. There was a validation step that was erroneously failing. This has been fixed.Fixes
- check for valid
source_pathwas failing in some instances - added test to valid
source_path😅 - updated README
- fixed some docstring typos
Downloads
-
Source code (ZIP)
1 download
-
Source code (TAR.GZ)
1 download
- check for valid
-
v0.3.0 Stable
released this
2025-11-19 07:52:50 +01:00 | 6 commits to main since this releaseSummary
In HTML,
<img>tags are considered ininline-blockelements. Some markdown to html parsers will render images within<p>tags, which makes it awkward if you're actually treatingimgtags likeblockelements.However, another approach is to wrap images in
<picture>or<figure>elements. In order to do that, theHTMLWriterclass and some of the properties had to be refactored to allow for this flexibility in the future. This will allow a user to choose whether they want their HTML rendered with or without those parent tags.As a result, using the
SrcsetItemandSizesproperties directly will also give the user more control as to how the markup is rendered. It was still important to provide sensible defaults for these values so that for most use cases, usingrenderon its own will suffice. But the option is there to be more surgical.Additionally, an option to add size mappings for the
sizekeywords has been added. This makes it easier to set defaults for one-off image resizes. Note, passing a tuple ofFeatures
- Output file with html snippet can now be saved as
mdandhtmlin addition totxt - Allow custom size mappings to be passed in for keyword scaling/resizing to override the default "small", "medium", "large", and "thumbnail" keywords. For example:
# Passed as a tuple of (width, height) # If height is "auto", the image will scale to the give width # For example, (100, "auto") means the height will be scaled accordingly # On the other hand, (100, 100) will try to `fit` the image within the constraint size_mapping = { "small": (100, 100), "big": (1000, 1000), "huge": (2400, 2400) } # Will render an image 2400 x 2400 pixels webimage.render(size="huge", size_mapping=size_mapping)- Allow for custom
srcsetandsizesattributes to be set with more control using custom properties. For example:
from _scribe import HTMLWriter from webimage.properties import Sizes, MediaCondition, SrcsetItem srcset_item = SrcsetItem( prepend_path="/img/static/", image_name="my_image", width=600, img_format="jpg", ) sizes = Sizes( media_conditions=[ MediaCondition( min_or_max_width="max", width_of_window=800, image_width=96, image_unit="vw", ), MediaCondition( min_or_max_width="max", width_of_window=1200, image_width=1200, image_unit="px", ), ] ) html_writer = HTMLWriter( srcset_items=[srcset_item], sizes=sizes, ) # Renders the following """ <img class="responsive-image" srcset= " /img/static/my_image.jpg 600w " src="/img/static/my_image.jpg" sizes="(max-width: 800px) 96vw, (max-width: 1200px) 1200px, 97vw" alt="..." /> """Fixes
- Removed
kwargsarguments fromPILmethods used byMage.transform - Removed unnecessary entry script in
pyproject.toml - Updated docstrings for clarity
- Removed redundant attribute (
img_format) fromHTMLWriter
Downloads
-
Source code (ZIP)
1 download
-
Source code (TAR.GZ)
1 download
- Output file with html snippet can now be saved as
-
v0.2.2 Stable
released this
2025-11-15 06:14:19 +01:00 | 16 commits to main since this release🧙♀️ WebImage 🧙♂️
WebImage has appeared!
Conjure responsive web images easily. Invoke snippets of the html to match the image renders.
from webimage import WebImage src_path: Path = path/to/img.jpg webimg = WebImage(src_path=src_path) # Creates default set (3 total) of responsive images webimg.render()The
rendermethod will create 3 images from the original in sizes ranging from 200px wide to 800px wide (retaining aspect ratio). It will also produce html text to plug in to your website.It will look a little like this:
<img class="webimage" srcset= " image_200w.png 200w, image_600w.png 600w, image_800w.png 800w " src="image_800w.png" sizes="(max-width: 800px) 96vw, 800px" alt="..." />Check out the README file for more info.
Downloads
-
Source code (ZIP)
1 download
-
Source code (TAR.GZ)
1 download
-
Source code (ZIP)