SVG thumbnail renderer
Adds an SVG renderer for thumbnails using Qt's QSvgRenderer that writes to a QImage that is written onto a QBuffer that PIL can then read as an image. ~~However, it does have an issue that I have been unable to resolve: Sometimes thumbnails seem to write over each other or otherwise be corrupted (no affect on the actual files though). I think it's due to the QPainter painting in a thread, but I'm not sure. You can see an example of this problem below:~~
Image no longer relevant
Sometimes thumbnails seem to write over each other or otherwise be corrupted
Yeah, that sounds like a multithreading issue since the thumb_renderer is multithreaded
@CyanVoxel I wonder if a future change would make sense, add a context manager so that it handles the buildup and teardown of thumbnails.
nice work, but as always - when adding a new feature, please add a test.
For this one having some sample .svg image alongside the test, and then compare the output via syrupy that it really provides the expected output. I made a similar test in some other project, so it could look something like this:
from syrupy.extensions.image import PNGImageSnapshotExtension
def test_svg_to_png(snapshot):
file_path = Path(__file__).parent / "fixtures" / "sample.svg"
png_image = ThumbRenderer(...)._image_vector_thumb(file_path, 600)
assert png_image.read() == snapshot(extension_class=PNGImageSnapshotExtension)
also what's the git branch thumbnails? Wouldnt be better to aim this either to the Alpha-9.4 or main?
I'm moved this PR from the deprecated thumbnails branch to Alpha-v9.4, which is the branch that thumbnails was eventually merged into. However the v9.4.x releases are now feature frozen and are now solely reserved for bugfixes. This means that after the changes from thumbnails are ported to main that I'll once again be moving the target for this PR over to there as a v9.5 feature.
Sorry for the disruption, and thank you for your patience.
I've ported this functionality to main via #540, thank you for your contribution with this!