-
Hi! I am currently working on a pathology-related project where I am dealing with (very) large-sized images. I chose However, after searching through the
Thank you for your assistance! Best, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ido-nuc, The simplest solution is just to draw them with SVG: import pyvips
x = pyvips.Image.svgload_buffer(b"""
<svg viewBox="0 0 200 200">
<circle r="100" cx="100" cy="100" fill="#900"/>
</svg>
""")
x.write_to_file("x.png") To make: The SVG loader is progressive, so it can draw SVGs of any size (up to 32k x 32k pixels) using only a modest amount of memory. You can make masks by just taking the alpha, you can combine masks with the boolean operators, and you can render stacks of RGBA images with The 32k pixel limit is unfortunate :( It comes from cairo, sadly, and isn't really fixable. We are considering switching to another SVG renderer, but no one's done the work yet. Don't use the Another option is to use x = pyvips.Image.xyz(501, 501) - [250, 250]
x = (x[0] ** 2 + x[1] ** 2) ** 0.5 < 200 Will draw a circle with a radius of 200 in the centre of a 500 x 500 pixel image, for example. |
Beta Was this translation helpful? Give feedback.
Hi @ido-nuc,
The simplest solution is just to draw them with SVG:
To make:
The SVG loader is progressive, so it can draw SVGs of any size (up to 32k x 32k pixels) using only a modest amount of memory. You can make masks by just taking the alpha, you can combine masks with the boolean operators, and you can render stacks of RGBA images with
composite
.The 32k pixel limit is unfortunate :( It comes from cairo, sadly, and isn't really fixable. We are considering switching to another SVG renderer, but no one's done…