svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.14k stars 1.08k forks source link

Proportional Resize Not Required #1082

Closed waliarubal closed 4 years ago

waliarubal commented 4 years ago

I have added a few image objects, when I am trying to resize the image using the size(width, height) method, images are maintaining aspect ratio which I don't want. Here is an example.

Lets say their is an image of size 320 x 240, now when I am calling size method with values other than a proper proportion, resizing is not working. For instance if I pass 100 x 200 in size method, image doesn't resize or it maintains an aspect ratio.

I would like image to take whatever size I need to resize the image to whatever value is provided without it maintaining the aspect ratio. Please let me know how to achieve this?

Fuzzyma commented 4 years ago

Set the attribute preserveAspectRatio="none" on the image. This issue is actually not related to the size function. Its just the way svg calculates size for you when you dont set preserveAspectRatio="none"

waliarubal commented 4 years ago

Thanks, that worked like a charm.