Re: Converting SVG to SVG and replacing viewBox

2021-03-20 Thread Helder Magalhães
Hello Konstantin,

Because SVG is vector graphics, you don't have to resize the whole contents
but only the viewBox, as you've already stated.
In this case, Batik would be overkill in my opinion: a simple XML
manipulation workflow would be sufficient:

   1. open SVG (XML) document;
   2. read 'viewBox' attribute;
   3. possibly to some maths;
   4. edit 'viewBox' attribute;
   5. save document.

One might use Batik XML interfaces, of course, but it might be even simpler
to use a "plain" XML parser - such as TinyXML or pugixml (where there's a
nice benchmark  comparison with many
more, if there are performance-related goals involved).

Hope this helps,
Helder


Konstantin Bulenkov  escreveu no dia quinta,
11/03/2021 à(s) 19:47:

> Hello everyone,
>
> What's a proper way to convert an SVG image file and replace its viewBox
> size, and then save?
>
> For example, loading 32x32 svg file, and save it as 16x16.
>
> input:
>
>  xmlns="http://www.w3.org/2000/svg;>
> 
> 
> 
> 
>  y2="26.4673" gradientUnits="userSpaceOnUse">
> 
> 
> 
> 
> 
> 
>
> output (using Figma):
>
>  xmlns="http://www.w3.org/2000/svg;>
> 
> 
>  x2="9.9591" y2="13.2336" gradientUnits="userSpaceOnUse">
> 
> 
> 
> 
> 
> 
>
> My first attempt was to use SVGGraphics2D with loaded svg document and then 
> change svgCanvasSize. However, I got invalid file with missing defs and 
> invalid formatting.
>
> Thank you in advance for any help.
>
> Konstantin
>
>
>


Converting SVG to SVG and replacing viewBox

2021-03-11 Thread Konstantin Bulenkov
Hello everyone,

What's a proper way to convert an SVG image file and replace its viewBox
size, and then save?

For example, loading 32x32 svg file, and save it as 16x16.

input:

http://www.w3.org/2000/svg;>












output (using Figma):

http://www.w3.org/2000/svg;>










My first attempt was to use SVGGraphics2D with loaded svg document and
then change svgCanvasSize. However, I got invalid file with missing
defs and invalid formatting.

Thank you in advance for any help.

Konstantin