ImageMagick / ImageMagick/ImageMagick
MagickWand: significant performance drop when stroking paths with scale > 1
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.5k
- Forks
- 1.7k
- Avg merge
- 10h 17m
- Merged PRs (30d)
- 28
Description
ImageMagick version
7.1.1-46
Operating system
Linux
Operating system, version and so on
Ubuntu 22.04 LTS
Description
We encountered some very strange behavior when drawing geometries.
Here is an example of what we want to draw (50_000 circles):
This works satisfactorily fast (about 4 seconds) in three out of four cases. But when the circle has a stroke and the scaling in the transformation is greater than one, there is a sharp drop in performance—drawing takes 44 seconds.
The situation is even worse if the circle is drawn using a path (arc with angle=2*PI). In this case, drawing 50,000 circles will not complete.
Steps to Reproduce
These images are automatically generated by our library. The MVG is dumped using the DrawGetVectorGraphics function.
DrawCircle test:
- Unzip circle_50000.zip
- Run
magick -size 600x400 mvg:./circle_50000.mvg circle_50000.png
Result: conversion takes acceptable time, like ~5 seconds (could be better, though?) - Unzip circle_50000@2x.zip
- Run
magick -size 1200x800 mvg:./circle_50000@2x.mvg circle_50000@2x.png
Result: conversion takes unacceptable 40+ seconds, yet the only difference is theaffine 2 0 0 2 0 0at the beginning of the file.
DrawPath* test:
- Unzip path_10000.zip
- Run
magick -size 800x400 mvg:./path_10000.mvg path_10000.png
Result: converted in zero seconds. - Unzip path_10000@2x.zip
- Run
magick -size 1200x800 mvg:./path_10000@2x.mvg path_10000@2x.png
Result: conversion takes unacceptable 5 seconds to draw just 10_000 circles, yet the only difference is theaffine 2 0 0 2 0 0at the beginning of the file.
Images
circle_50000.zip
circle_50000@2x.zip
path_10000.zip
path_10000@2x.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the slowdown with the supplied circle_50000, circle_50000@2x, path_10000, and path_10000@2x MVG archives using the documented magick commands. Start by comparing rendering with and without the affine scale and trace the MagickWand drawing path handling. Done means scaled stroked circles and paths render without the reported severe performance regression, with benchmarks covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cli, computer-graphics, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100