While the dimensions a animated GIF should have can be specified exactly in GrabzIt you can also just specify one dimension with the other defined as -1.
This will scale the video to the size of the specified dimension, the other unspecified dimension will also be reduced in the same ratio. However the size of the unspecified dimension will of course vary depending on the dimensions of the source video.
The advantage of this technique is that it allows an entire video to be scaled down to a small size without any padding or cropping. Below is an example showing a animated GIF with a width of 200px and the height being auto-sized depending on the ratio of the 200px width to the source video width.
//The client should be stored somewhere and reused! GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret", client); AnimationOptions options = new AnimationOptions(); options.Width = 200; options.Height = -1; grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options); await grabzIt.SaveAsync("http://www.mywebsite.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); AnimationOptions options = new AnimationOptions(); options.setWidth(200); options.setHeight(-1); grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options); grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.5.2/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("https://www.youtube.com/watch?v=a1Y73sPHKxw",
{"format":"gif", "width":200, "height":-1}).Create();
</script>
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw", {"width":200, "height":-1}); client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = GrabzItAnimationOptions->new(); $options->width(200); $options->height(-1); $grabzIt->URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", $options); $grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = new \GrabzIt\GrabzItAnimationOptions(); $options->setWidth(200); $options->setHeight(-1); $grabzIt->URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", $options); $grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItAnimationOptions.GrabzItAnimationOptions() options.width = 200 options.height = -1 grabzIt.URLToAnimation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options) grabzIt.Save("http://www.mywebsite.com/handler.py")
https://api.grabz.it/convert?key=Sign in to view your Application Key&format=gif&width=200&height=-1&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Da1Y73sPHKxw
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzIt::AnimationOptions.new() options.width = 200 options.height = -1 grabzIt.url_to_animation("https://www.youtube.com/watch?v=a1Y73sPHKxw", options) grabzIt.save("http://www.mywebsite.com/handler/index")
When calculating the Total Resolution of the Animated GIF, to determine if it is allowed on your current package, the value of the non-auto-sizing dimension is used instead.