<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yakir Perlin on Medium]]></title>
        <description><![CDATA[Stories by Yakir Perlin on Medium]]></description>
        <link>https://medium.com/@yakirperlin?source=rss-5653273a7547------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Jj2fc0CfJnYr4MG6wr2lLQ.png</url>
            <title>Stories by Yakir Perlin on Medium</title>
            <link>https://medium.com/@yakirperlin?source=rss-5653273a7547------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 23:21:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yakirperlin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Easy Image Loading and Optimization with Cloudinary and Fresco]]></title>
            <link>https://medium.com/@yakirperlin/easy-image-loading-and-optimization-with-cloudinary-and-fresco-4df03f8183c5?source=rss-5653273a7547------2</link>
            <guid isPermaLink="false">https://medium.com/p/4df03f8183c5</guid>
            <category><![CDATA[image-optimization]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[cloudinary]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Yakir Perlin]]></dc:creator>
            <pubDate>Tue, 14 Nov 2017 18:23:24 GMT</pubDate>
            <atom:updated>2017-11-15T20:10:19.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*07uHx3UKakfyYQFcwMXREg.gif" /><figcaption><em>Annoying ?</em></figcaption></figure><p>As mobile developers, when talking about images and videos, one of our main concerns is creating a smooth and amazing experience for our users, no matter what kind of device or network connection they are using. In this article, I’m going to show you how you can easily improve this experience using <a href="https://cloudinary.com/">Cloudinary</a> and <a href="http://frescolib.org/">Fresco</a>.</p><p>In Android, working with images (bitmaps) is really difficult because the application runs out of memory (OOM) very frequently. OOM is the biggest nightmare for Android developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*0hTcjWXj85prs7_VuVR9_g.gif" /></figure><p>There are some well known open source libraries that can help us deal with such problems like Picasa, Glide, and Fresco.</p><p>Fresco (by Facebook) is my favorite. Fresco is written in C/C++. It uses ashmem heap instead of VM heap. Intermediate byte buffers are also stored in the native heap. This leaves a lot more memory available for applications to use and reduces the risk of OOMs. It also reduces the amount of garbage collection required, leading to better performance and a smoother experience in our app. Another cool thing is that Fresco supports multiple images (multi-URI), requesting different image qualities per-situation, which help us further improve the user experience in cases of poor connectivity for example.</p><h3>Multiple Image (Multi-URI) Requests</h3><p>Suppose you want to show your users a high-resolution, relatively slow-to-download image. Rather than let them stare at a placeholder or a loading spinner for a while, you might want to quickly download a smaller thumbnail first. With Fresco this can be done by setting two image URIs, one for the low-resolution image, and one for the high-resolution one:</p><pre>Uri lowResUri, highResUri;</pre><pre>DraweeController controller = Fresco.newDraweeControllerBuilder() .setLowResImageRequest(ImageRequest.fromUri(lowResUri)) .setImageRequest(ImageRequest.fromUri(highResUri)) .setOldController(mSimpleDraweeView.getController()) .build();</pre><pre>mSimpleDraweeView.setController(controller);</pre><h3>But How I Can Generate Two Image Quality URIs?</h3><p>Cloudinary’s <a href="https://cloudinary.com/documentation/fetch_remote_images">fetch</a> functionality enables on-the-fly manipulation of remote images and optimized delivery via a super fast CDN. It allows us to easily and dynamically generate different image quality versions, regardless of the location of image.</p><p>Let’s say this is my original image, stored in my AWS S3 bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sANm3V13vN9SQRFGWHIerQ.png" /><figcaption><a href="https://s3.amazonaws.com/myappmedia/donut.png">https://s3.amazonaws.com/myappmedia/donut.png</a></figcaption></figure><p>You can see that this image’s size is almost 1MB. Loading many such images can sometimes harm your user’s experience while they are waiting for the image to fully load.</p><p>With Cloudinary, it’s super easy to fetch that image and generate both low and high-res image versions.</p><h4><strong>Fetching Remote Images With Cloudinary:</strong></h4><p>Here’s the basic URL template for fetching any remote image with Cloudinary:</p><pre>https://res.cloudinary.com/&lt;cloud&gt;/image/fetch/&lt;transformations&gt;/&lt;remote_image_url&gt;</pre><h4>Add Dynamic Transformations For Low Resolution:</h4><p>And here’s what the URL looks like when you add parameters that adjust the quality:</p><pre>https://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png</pre><p>This transformation converts the image (“<a href="http://res.cloudinary.com/yakir/image/upload/donut.png">donut</a>”) to WebP, scales it down to a 400-pixel width, sets the quality to auto:low (an algorithm automatically does a quality vs. size trade-off where relatively low quality is considered acceptable). These transformations reduce the image size from nearly a megabyte to 2.37 KB (!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*-F1jnr-35mUlK1wYB8gqtg.png" /><figcaption><a href="http://res.cloudinary.com/yakir/image/fetch/f_auto,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png">http://res.cloudinary.com/yakir/image/fetch/f_auto,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png</a></figcaption></figure><p><em>Note that in order to work with WebP, the only thing you need to do is add the </em><em>webpsupport library to your dependencies, like described </em><a href="http://frescolib.org/docs/webp-support.html"><em>here</em></a><em>.</em></p><h4>Add Dynamic Transformations For High Resolution:</h4><p>It’s important to note that you can also dynamically optimize your high quality 1MB image in order to make it more ideal for Android device screen sizes. So for your high-resolution version you can just change the quality parameter to “auto:best” and leave the width as it was for the low resolution. This transformation would generate a nice looking, small sized image of 6.88 KB.</p><pre>https://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*lIpWAsFLaubrRSlU38BzWg.png" /><figcaption><a href="http://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png">http://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png</a></figcaption></figure><p>To complete the example using Fresco, you just need to set those URLs for the low and high versions:</p><pre>String originalImageURL = &quot;https://s3.amazonaws.com/myappmedia/donut.png&quot;;</pre><pre>String lowResUri = &quot;https://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:low,w_400/&quot; + originalImageURL;</pre><pre>String highResUri = &quot;https://res.cloudinary.com/yakir/image/fetch/f_webp,q_auto:best,w_400/&quot; + originalImageURL;</pre><pre>DraweeController controller = Fresco.newDraweeControllerBuilder() .setLowResImageRequest(ImageRequest.fromUri(Uri.parse(low_res_url))) .setImageRequest(ImageRequest.fromUri(Uri.parse(high_res_url))) .setOldController(mSimpleDraweeView.getController()) .build();</pre><pre>mSimpleDraweeView.setController(controller);</pre><p>Pretty easy, right?</p><p>Images and videos are the core component of any mobile app. Using both Cloudinary and Fresco can dramatically improve your Android users’ experience with a small effort from your side as developers.</p><p>Feel free to ping me if you have any questions about this post or any other media optimization related issues.</p><p>In our next post we are going to talk about how to’ optimize video in your Android application, stay tuned-!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4df03f8183c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>