Converting Videos to GIFs in Kotlin-Based Android Apps With Cloudinary

Among the image formats available today, Graphics Interchange Format (GIF) works for both static and animated images. A popular use of GIF images—commonly called GIFs—is to repeatedly loop motions, which you cannot in real life. Many people have turned themselves into online celebrities through effective application of GIFs.

Cloudinary is a robust, cloud-based, end-to-end platform for uploads, storage, manipulations, optimizations, and delivery of images and videos. Notably for manipulations, you can add appeal to visual media by transforming them through resizing and application of various effects. 

This article steps you through the procedure of leveraging Cloudinary to convert a video in an Android demo app, written in Kotlin, to a GIF. It’s a helpful task well worth learning. 

Fulfilling the Preliminary Requirements

First, [create a Cloudinary account](https://cloudinary.com/users/register/free).

Second, [download Android Studio 3.4+](https://developer.android.com/studio/archive.html), which works well with Kotlin, as the IDE for developing the demo app.

Setting Up an Android Client

Now set up an Android client by following the steps in the subsections below.

Creating an Android Project

Open Android Studio and create an Android project.  

  1. In the Create Android Project screen, select the Empty Activity template. Click Next.


  1. In the Configure your project screen that is displayed, type the application name, package name, and so forth in the text fields. Select Kotlin as the language. Select API 16: Android 4.1 (Jelly Bean) from the pull-down menu as your minimum SDK, i.e., the lowest Android version supported by your app. Click Finish.


Configuring Cloudinary

Configure Cloudinary, as follows:

  1. Edit your project’s build.gradle file to add the Cloudinary dependency so as to gain access to Cloudinary’s features:

implementation group: 'com.cloudinary', name: 'cloudinary-android', version: '1.24.0'

  1. Edit the AndroidManifest.xml file and add the storage permissions under the uses-permission tag and the configurations under the application tag:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.cloudinarysample">
    
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  
    <application
        ...
        >
        
        <meta-data
            android:name="CLOUDINARY_URL"
            android:value="cloudinary://@myCloudName"/>

    </application>

</manifest>