diff --git a/src/bindings/wasm/tvgWasm.cpp b/src/bindings/wasm/tvgWasm.cpp index 924763a2..1a954423 100644 --- a/src/bindings/wasm/tvgWasm.cpp +++ b/src/bindings/wasm/tvgWasm.cpp @@ -220,7 +220,11 @@ public: return false; } - animation->picture()->size(width, height); + //keep the aspect ratio. + float ow, oh; + animation->picture()->size(&ow, &oh); + float scale = static_cast(width) / ow; + animation->picture()->size(ow * scale, oh * scale); auto saver = Saver::gen(); if (!saver) { diff --git a/src/tools/lottie2gif/lottie2gif.cpp b/src/tools/lottie2gif/lottie2gif.cpp index 0d61c517..0d3ec398 100644 --- a/src/tools/lottie2gif/lottie2gif.cpp +++ b/src/tools/lottie2gif/lottie2gif.cpp @@ -72,7 +72,10 @@ private: auto picture = animation->picture(); if (picture->load(in) != Result::Success) return false; - picture->size(static_cast(width), static_cast(height)); + float width, height; + picture->size(&width, &height); + float scale = static_cast(this->width) / width; + picture->size(width * scale, height * scale); auto saver = Saver::gen(); if (saver->save(std::move(animation), out, 100, fps) != Result::Success) return false;