/**  svg_size( +Svg, -Width, -Height )

Gets the size of an Svg.<br>
Remove pt from units and converts to numbers (iff possible).

==
?- svg_size( pack('svg/examples/rea_smp-e10_fclr.svg'), W, H ).
W = 497,
H = 404.
==

@author nicos angelopoulos
@version  0.1 2018/2/20
@see svg/2.

*/
svg_size( SvgIn, W, H ) :-
    svg( SvgIn, Svg ),
    Svg = svg(Atts,_),
    memberchk( width=Wat, Atts ),
    memberchk( height=Hat, Atts ),
    maplist( svg_size_dim, [Wat,Hat], [W,H] ).

svg_size_dim( At, NumIff ) :-
    ( atom_concat(AtNum,pt,At) -> true; AtNum is At ),
    ( catch(atom_number(AtNum,NumIff),_,fail) -> true; NumIff = AtNum ).
