C
C
coderisimo2018-12-07 13:34:34
PHP
coderisimo, 2018-12-07 13:34:34

How to create an SVG without setting a size so that Imagick doesn't crash?

I write my chart in SVG.
In some cases, to calculate the actual height and width of labels, I create SVG on the fly, insert text into it, and then get the actual size of the text via $image->getImageHeight() and $image->getImageWidth(). Everything worked fine until the Imagick version changed. Now I get the error
ImagickException - must specify image size.
I can set the size, but then everything loses its meaning))). After all, I specifically use dimensionless SVG to figure out the size of the text ...
If you have ideas how to win this, please share.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2018-12-07
@coderisimo

Attention, correct answer). Obtained by experience.
set to any reasonable size.
and then we do voila, we get a cropped image. That is, the picture is cropped according to the content. Maybe it will be useful for someone

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question