<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adi Mizrahi</title>
    <description>The latest articles on DEV Community by Adi Mizrahi (@adimiz).</description>
    <link>https://dev.to/adimiz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F994847%2F78eceae0-5718-456b-8b84-1fa29a6dd0ff.jpg</url>
      <title>DEV Community: Adi Mizrahi</title>
      <link>https://dev.to/adimiz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adimiz"/>
    <language>en</language>
    <item>
      <title>Application Loading Speed Impact</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Tue, 28 Feb 2023 16:02:51 +0000</pubDate>
      <link>https://dev.to/adimiz/application-loading-speed-impact-41pp</link>
      <guid>https://dev.to/adimiz/application-loading-speed-impact-41pp</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;We all want to make the most impactful native application we can, we want to build rich, visual, successful applications!&lt;/p&gt;

&lt;p&gt;We try to consider everything: what is the goal/purpose of the application, the design, architecture, colors theme, dark mode support, does it require authentication, supported devices, and more…&lt;/p&gt;

&lt;p&gt;There’s one area where we lack initial thought, and we do not always put our finger on it and understand its importance.&lt;/p&gt;

&lt;p&gt;How fast our application loads, from the moment the user clicks the application icon till the moment he gets the first visual screen, the amount of time a user has to wait is crucial and important to the success of the application.&lt;/p&gt;

&lt;p&gt;It’s important to note that users tend to have high expectations for app performance, and a slow-loading app can lead to poor user engagement and retention. As a result, it’s important for developers to optimize their apps for speed and ensure that they launch as quickly as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Reason
&lt;/h2&gt;

&lt;p&gt;I want to start off with the why, and why applications load slowly. what are the main reasons that might cause an app to take a long time to interact with the user?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Large app size&lt;/strong&gt;: If the app size is too large, it can take a long time for the application to download and install on the user’s device. This can significantly slow down the launch time.
Poor network conditions: If the device is connected to a slow or congested network, it can impact the time it takes for data and assets to be downloaded, leading to a slow app launch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource-intensive operations&lt;/strong&gt;: If the app performs resource-intensive operations during launch, such as loading large amounts of data from the network or parsing complex data structures, this can slow down the launch time.
Unoptimized code: If the app’s code is not optimized for performance, it can take longer for the app to launch. This may include inefficient algorithms, excessive use of memory, or poorly optimized graphics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background processes&lt;/strong&gt;: If the device is running multiple background processes, this can reduce the available resources for the app and slow down its launch time.
Outdated hardware: If the device is running on outdated hardware, it may not have the processing power or memory required to launch the app quickly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third-party libraries&lt;/strong&gt;: If the app relies on third-party libraries, the time it takes to load those libraries can significantly impact the launch time. It’s important to ensure that the libraries are up-to-date and optimized for performance.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Impacts of Slow-Loading Applications
&lt;/h2&gt;

&lt;p&gt;We’ve seen what might cause the application to load slowly, let’s talk about the impacts, what will be the impacts of a slow-loading application?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Poor user experience&lt;/strong&gt;: A slow-loading app can lead to frustration and a poor overall user experience. Users expect apps to launch quickly and be responsive, and a slow-loading app can detract from their enjoyment of the app.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decreased engagement&lt;/strong&gt;: A slow-loading app may discourage users from using the app and reduce their overall engagement. Users may be less likely to use the app if it takes a long time to launch and is slow to respond to their inputs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decreased retention&lt;/strong&gt;: A slow-loading app can lead to decreased user retention over time. Users are more likely to uninstall an app that takes a long time to launch and is slow to respond.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decreased conversions&lt;/strong&gt;: For e-commerce apps, slow loading times can lead to decreased conversions as users may abandon the app before completing a purchase.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Negative reviews&lt;/strong&gt;: Slow-loading apps can lead to negative reviews and ratings in app stores, which can impact the app’s visibility and success.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Numbers
&lt;/h2&gt;

&lt;p&gt;We’ve seen the impact, let’s talk numbers and percentages, how much will it hurt our application if it loads slowly?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;User engagement&lt;/strong&gt;: Research has shown that a 1-second delay in app load time can lead to a 7% reduction in user engagement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User retention&lt;/strong&gt;: A study found that a 1-second delay in app load time can lead to a 16% decrease in user satisfaction and a 4.1% decrease in daily active users.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Conversions&lt;/strong&gt;: Slow app load times can also impact conversions, with research showing that a 1-second delay in app load time can lead to an 11% reduction in conversions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Negative reviews&lt;/strong&gt;: Slow-loading apps are more likely to receive negative reviews and ratings, with research suggesting that users are up to 3 times more likely to leave a negative review for an app that takes more than 3 seconds to launch.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article we showed why is loading speed of an application is so important, why showed the reason we want to improve and optimize our application load time, the impact a slow loading application can cause, and the numbers the “What’s in it for me?”&lt;/p&gt;

&lt;p&gt;When designing an application be sure to take this factor into consideration as it’s an essential factor for your application’s success.&lt;/p&gt;

</description>
      <category>mobile</category>
      <category>android</category>
      <category>ios</category>
      <category>flutter</category>
    </item>
    <item>
      <title>iOS (Swift) — Custom Transitions</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Mon, 02 Jan 2023 18:45:28 +0000</pubDate>
      <link>https://dev.to/adimiz/ios-swift-custom-transitions-5647</link>
      <guid>https://dev.to/adimiz/ios-swift-custom-transitions-5647</guid>
      <description>&lt;p&gt;While developing multiple apps through my years as an iOS developer, I was requested more than once to make a different custom transition between screens than what the iOS system default transitions have to offer.&lt;/p&gt;

&lt;p&gt;In this article, I’ll show the basic transition the iOS system gives us, and how to create your own custom transition when moving between &lt;code&gt;UIViewController&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Default transition
&lt;/h2&gt;

&lt;p&gt;Imagine the following scenario, we have a button on the screen, when the user taps the button another screen with full-screen red background shows up.&lt;br&gt;
The red background &lt;code&gt;UIViewController&lt;/code&gt; will cover the current &lt;code&gt;UIViewController&lt;/code&gt; from bottom to top, this is the default iOS transition and it’s called &lt;code&gt;.coverVertical&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To present a &lt;code&gt;UIViewController&lt;/code&gt; from another &lt;code&gt;UIViewController&lt;/code&gt; we can use the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let redViewController = UIStoryboard(name: "Main", bundle: nil)
                        .instantiateViewController(identifier: "redViewController")
redViewController.modalPresentationStyle = .fullScreen
self.present(redViewController, animated: true)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As mention before let us see all the transitions options the iOS system give us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.coverVertical&lt;/code&gt; — this is the default behavior the iOS system gives us, the presented &lt;code&gt;UIViewController&lt;/code&gt; covers the presenting &lt;code&gt;UIViewController&lt;/code&gt; from bottom to top.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.flipHorizontal&lt;/code&gt; — flips the presenting &lt;code&gt;UIViewController&lt;/code&gt; horizontally and presenting the new &lt;code&gt;UIViewController&lt;/code&gt; on the other side.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.crossDissolve&lt;/code&gt; — fades the presenting &lt;code&gt;UIViewController&lt;/code&gt; to the presented &lt;code&gt;UIViewController&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.partialCurl&lt;/code&gt; — flips the presenting &lt;code&gt;UIViewController&lt;/code&gt; to the presented UIViewController from bottom to top like a page in a book.
An example of how to use a different iOS default transition than &lt;code&gt;coverVertical&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func openRedViewController() {
  let redViewController = UIStoryboard(name: "Main", bundle: nil)
                          .instantiateViewController(identifier: "redViewController")
  redViewController.modalPresentationStyle = .fullScreen
  redViewController.modalTransitionStyle = .partialCurl
  self.present(redViewController, animated: true)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’ve added the &lt;code&gt;.modalTransitionStyle&lt;/code&gt; to our &lt;code&gt;UIViewController&lt;/code&gt; and set its property to &lt;code&gt;.partialCurl&lt;/code&gt;, so now we don't get &lt;code&gt;coverVertical&lt;/code&gt; transition but &lt;code&gt;paritalCurl&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;Those four transitions are the basic transitions the iOS system gives us, but what if we wanted more? What if we want a different transition? What if we want to control the velocity, timing, alignment, and more? How can we do that?&lt;/p&gt;

&lt;p&gt;The following code shows us how to create a “push” transition from right to left:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func createPushRightToLeftTransition() -&amp;gt; CATransition {
  let transition: CATransition = CATransition()
  transition.startProgress = 0.0
  transition.endProgress = 1.0
  transition.type = .push
  transition.subtype = .fromRight
  transition.duration = 0.3
  return transition
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Firstly we create an object of type CATransition this object will contain all the properties we need to achieve the transition we want:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;startProgress&lt;/code&gt; — Indicates the start point of the receiver as a fraction of the entire transition.
endProgress — Indicates the endpoint of the receiver as a fraction of the entire transition.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;type — the name of the transition, multiple options we have here:
fade, moveIn, push and reveal.
Default&lt;/code&gt;isfade`.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subtype&lt;/code&gt; — An optional subtype for the transition. used to specify the transition direction for motion-based transitions, values: &lt;code&gt;fromLeft&lt;/code&gt;, &lt;code&gt;fromRight&lt;/code&gt;, &lt;code&gt;fromTop&lt;/code&gt;, &lt;code&gt;fromBottom&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;duration&lt;/code&gt; — The basic duration of the transition. (seconds)
We just created our transition object, but how do we use it? Let’s take a look at the following code:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;`&lt;br&gt;
func openRedViewController() {&lt;br&gt;
  let redViewController = UIStoryboard(name: "Main", bundle: nil)&lt;br&gt;
                          .instantiateViewController(identifier: "redViewController")&lt;br&gt;
  let transition = createPushRightToLeftTransition()&lt;br&gt;
  self.view.window?.layer.add(transition, forKey: "kCATransition")&lt;br&gt;
  self.present(redViewController, animated: false)&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Again, as we have seen before we are creating our `redViewController` object, but there are two main changes here so we can use our custom transition.

- We added a new line, on the view.window` where we add to its layer our custom transition.
when we call `self.present` we have to set the animated parameter to false.
- Those two conditions will allow us to use our custom transition, once we call this function the `redViewController` will be pushed from right to left in 0.3 seconds.

Let’s see another example of a custom transition, this time we are going to create a fade transition, where the presenting `UIViewController` fade out and the presented `UIViewController` fades in:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;func createFadeTransition() -&amp;gt; CATransition {&lt;br&gt;
  let transition: CATransition = CATransition()&lt;br&gt;
  transition.type = .fade&lt;br&gt;
  transition.duration = 0.75&lt;br&gt;
  return transition&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;As we did before, we create our `CATransition` object, but this time we use fade as our type for the transition, we then set the duration to 0.75 seconds.

As same as we did before with presenting a `UIViewController` with a custom transition, we can do the same when want to dismiss a `UIViewController`, take a look at the following code snippet:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;func dismissViewController() {&lt;br&gt;
  let transition = createFadeTransition()&lt;br&gt;
  self.view.window?.layer.add(transition, forKey: "kCATransition")&lt;br&gt;
  self.dismiss(animated: false, completion: nil)&lt;br&gt;
}&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

Important to remember here is to set the animated property for the dismiss function to false otherwise, our custom transition will not work.

## Conclusion
CATransition object is great to create different and custom transitions. we have a variety of types and subtypes with can use to create many custom transitions, we can also set the duration of the transition, the start point, and the endpoint.
For more reading about custom transitions please click [here](https://developer.apple.com/documentation/quartzcore/catransition).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Cloudinary with Android</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Fri, 23 Dec 2022 20:31:04 +0000</pubDate>
      <link>https://dev.to/adimiz/cloudinary-with-android-582n</link>
      <guid>https://dev.to/adimiz/cloudinary-with-android-582n</guid>
      <description>&lt;p&gt;For years I’ve been an Android developer, and only in recent months have I gotten to dive back into the Android world (after years of iOS development).&lt;/p&gt;

&lt;p&gt;As I mentioned in my previous &lt;a href="https://dev.to/adimiz/cloudinary-with-swiftios-4nhe"&gt;iOS post&lt;/a&gt; a few months ago I joined a great company Cloudinary and that’s what I’ll write about today.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;In one of my previous jobs, I was responsible for an application that allows you as the user to download images into your phone and set them as a background for the home screen, lock screen, or both.&lt;br&gt;
This application requires pulling big JSON files with all the image information, each image having multiple fields such as title, URL, created date, etc…&lt;br&gt;
On the main screen, I had to present a thumbnail (A thumbnail is a small image representation of a larger image) of each image.&lt;br&gt;
Tapping a thumbnail will direct the user to a screen where the image is shown full screen.&lt;br&gt;
These 2 screens already required multiple versions of the same image. Since you can’t present a full-screen image with a thumbnail image because you’ll get a pixelated result which yields a bad user experience. On the other hand, We don’t want to present the full-screen image on the main screen (where we show many images on a screen) because it’ll cause a long load time of the screen. Which is again a bad user experience.&lt;/p&gt;

&lt;p&gt;Other than that, each image has various sizes that we need to present, and let us not forget that the application supports multiple devices with different screen sizes, many manufacturers, phones, tablets, etc… which require different sizes of the image.&lt;br&gt;
So how can we handle this? We have one image, but we need it in many different sizes. We can take it on the client side and manipulate the image on the device but that won't be efficient.&lt;br&gt;
We can ask our server side (if we have one) to give us multiple URLs for each image but that will make the JSON response huge and hard to handle.&lt;/p&gt;

&lt;p&gt;This is where Cloudinary comes in.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Solution!
&lt;/h2&gt;

&lt;p&gt;As you might have guessed the solution will be Cloudinary&lt;br&gt;
&lt;strong&gt;What is Cloudinary?&lt;/strong&gt;&lt;br&gt;
Cloudinary is a platform that allows you to quickly and easily create, manage and deliver digital experiences across any browser, device, and bandwidth.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use Cloudinary?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;br&gt;
The first thing you need to do is go to the Cloudinary website and sign-up for a free account.&lt;/p&gt;

&lt;p&gt;You can find the git repository for the Android SDK here.&lt;br&gt;
To integrate Cloudinary into your app you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Gradle
implementation 'com.cloudinary:cloudinary-android:2.2.0'
//Maven
&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;com.cloudinary&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;cloudinary-android&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;2.2.0&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Configuration&lt;/strong&gt;&lt;br&gt;
Once the package is integrated, we’ll need to set up our Cloudinary object.&lt;br&gt;
Your API-Key and Cloud-Name will appear in the dashboard where you created your account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frl88kv1celyx7h55pxg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frl88kv1celyx7h55pxg7.png" alt="Image description" width="700" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we have our Cloudinary object set and ready to use that’s where the &lt;strong&gt;MAGIC&lt;/strong&gt; starts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upload your assets&lt;/strong&gt;&lt;br&gt;
There are multiple ways to upload an asset to your cloud, via the API or the UI&lt;br&gt;
UI —It’s as simple as dragging and dropping into your cloud.&lt;br&gt;
API — You can upload through the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String requestId = MediaManager.get().upload(imageFile).unsigned("sample_preset").callback(callback).dispatch();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only thing we’re missing here is the upload preset. An upload preset is a field we need to set through the UI. You can do this by going to the Cloudinary &lt;a href="https://cloudinary.com/" rel="noopener noreferrer"&gt;website&lt;/a&gt;, signing in, and clicking the settings icon at the top right. Click the upload option, scroll down and add a new upload preset, There are many options to customize an upload preset but I’m not going to dive into them in this blog. Check out the &lt;a href="https://training.cloudinary.com/" rel="noopener noreferrer"&gt;Cloudinary Academy&lt;/a&gt; to learn more about what’s possible with Cloudinary’s APIs.&lt;/p&gt;

&lt;p&gt;Once the upload preset is created, be sure to put its name in the upload preset field in the unsigned function.&lt;br&gt;
Yes, that simple to upload an asset to your cloud, once the image is there we can start using transformations!&lt;br&gt;
Transformations are manipulations we can perform on an asset (image, video, etc…) there are many transformations and if you want to learn more than the examples I show here I suggest visiting Cloudinary’s &lt;a href="https://cloudinary.com/documentation/image_transformations" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transformations&lt;/strong&gt;&lt;br&gt;
At the start of this article, I presented the problem where we have one asset, but we need it in many different sizes and aspect ratios. Let’s see how we can achieve that very easily using Cloudinary’s transformations: (I’m going to use an asset called sample)&lt;/p&gt;

&lt;p&gt;The original image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feiv0128nxxs4k09dfhuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feiv0128nxxs4k09dfhuo.png" alt="Image description" width="700" height="466"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Crop&lt;/strong&gt;&lt;br&gt;
We want to create a thumbnail(250x250) for our main screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = MediaManager.get().url()
  .transformation(new Transformation()
  .crop("crop").width(250)
  .height(250))
.generate("big_image_sample");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me explain the code line above. We’re using the &lt;code&gt;MediaManager&lt;/code&gt; object we created before, we call the &lt;code&gt;url()&lt;/code&gt; function and setting a new transformation where we give all the parameters we want to modify in the image, lastly we call &lt;code&gt;generate&lt;/code&gt; with the asset name (sample).&lt;br&gt;
This line of code will produce the following &lt;a href="https://res.cloudinary.com/test123/image/upload/c_crop,h_250,w_250/sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvengafkapfuunwc9j6i9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvengafkapfuunwc9j6i9.png" alt="Image description" width="250" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see we got the 250x250 thumbnail we wanted, but the result could be improved. The “bee” which is the most interesting object in the image is cut off. What can we do? OH! Cloudinary has a few more tricks up its sleeve! Another COOL feature we can use “gravity” where we can ask Cloudinary to focus on the most interesting object in the image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gravity&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = MediaManager.get().url()
  .transformation(new Transformation()
  .crop("crop").width(250).height(250).gravity("auto"))
.generate("big_image_sample");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output &lt;a href="https://res.cloudinary.com/test123/image/upload/c_crop,h_250,w_250,g_auto/sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5r16l85760gmc6138fce.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5r16l85760gmc6138fce.png" alt="Image description" width="250" height="250"&gt;&lt;/a&gt;&lt;br&gt;
And as we can see the result is much better. The focus is on the bee.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quality&lt;/strong&gt;&lt;br&gt;
Let’s try another scenario. We have a 2k image, which is quite a large file, and we don’t need it in its best form when we’re presenting it on the device. Roaming can’t always handle big bandwidth. To make the image lighter we can use the Cloudinary “quality” feature.&lt;/p&gt;

&lt;p&gt;Here’s the original image (it weighs 5MB which is quite a large file)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasmvo3s6gmavn9ss4zgu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasmvo3s6gmavn9ss4zgu.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Cloudinary we can do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = MediaManager.get().url()
.transformation(new Transformation()
  .quality("auto"))
.generate("big_image_sample");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will produce the following &lt;a href="https://res.cloudinary.com/db0edm7to/image/upload/q_auto/big_image_sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5h8cjnifrf00p7djpyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5h8cjnifrf00p7djpyy.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it weighs 626.56 KB. So we reduced the size by a lot, and it’ll be easier to get this image on a mobile device.&lt;/p&gt;

&lt;h2&gt;
  
  
  To sum up!
&lt;/h2&gt;

&lt;p&gt;As we saw in the blog, Cloudinary can answer the requirement to handle the same asset in many sizes and qualities. Not only that it has many other features! I encourage you to visit the &lt;a href="https://cloudinary.com/documentation/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; website to get the best out of the platform.&lt;/p&gt;

&lt;p&gt;The Cloudinary SDK can also be found on &lt;a href="https://github.com/cloudinary/cloudinary_ios" rel="noopener noreferrer"&gt;iOS&lt;/a&gt; and 14 more languages you can find at &lt;a href="https://github.com/cloudinary" rel="noopener noreferrer"&gt;Cloudinary’s git&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Cloudinary with Swift(iOS)</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Fri, 23 Dec 2022 20:23:09 +0000</pubDate>
      <link>https://dev.to/adimiz/cloudinary-with-swiftios-4nhe</link>
      <guid>https://dev.to/adimiz/cloudinary-with-swiftios-4nhe</guid>
      <description>&lt;p&gt;Hi! Adi here. Been a while since I wrote. Switched jobs a few months ago, and it took most of my capacity, so I wasn't able to write. I’ve joined a great company called Cloudinary, and it is part of the reason I’m writing this blog. So let’s get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem!
&lt;/h2&gt;

&lt;p&gt;In one of my previous jobs, I was responsible for an application that allows you as the user to download images into their phone and set them as a background for the home screen, lock screen, or both.&lt;br&gt;
This application requires pulling big JSON files with all the image information, each image having multiple fields such as title, URL, created date, etc…&lt;/p&gt;

&lt;p&gt;On the main screen, I had to present a thumbnail (A thumbnail is a small image representation of a larger image) of each image.&lt;br&gt;
Tapping a thumbnail will direct the user to a screen where the image is shown full screen.&lt;/p&gt;

&lt;p&gt;These 2 screens already required multiple versions of the same image. Since you can't present a full-screen image with a thumbnail image because you’ll get a pixelated result which yields a bad user experience. On the other hand, We don't want to present the full-screen image on the main screen (where we show many images on a screen) because it’ll cause a long load time of the screen. Which is again a bad user experience.&lt;/p&gt;

&lt;p&gt;Other than that, each image has various sizes that we need to present, and let us not forget that the application supports multiple devices with different screen sizes, iPhones, iPads, and iPods which require different sizes of the image.&lt;/p&gt;

&lt;p&gt;So how can we handle this? We have one image, but we need it in many different sizes. We can take it on the client side and manipulate the image on the device but that won't be efficient.&lt;/p&gt;

&lt;p&gt;We can ask our server-side (if we have one) to give us multiple URLs for each image but that will make the JSON response huge and hard to handle.&lt;/p&gt;

&lt;p&gt;This is where Cloudinary comes in.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Solution!
&lt;/h2&gt;

&lt;p&gt;As you might have guessed the solution will be Cloudinary&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Cloudinary?&lt;/strong&gt;&lt;br&gt;
Cloudinary is a platform that allows you to quickly and easily create, manage and deliver digital experiences across any browser, device, and bandwidth.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to use Cloudinary?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;br&gt;
The first thing you’ll need to do is go to the Cloudinary website and sign-up for a free account. You can find the git repository for the iOS SDK here. To integrate Cloudinary into your app you can use:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;CocoaPods:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pod 'Cloudinary', '~&amp;gt; 3.0'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Carthage:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;github "cloudinary/cloudinary_ios" ~&amp;gt; 3.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Swift package manager:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/cloudinary/cloudinary_ios.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Configuration&lt;/strong&gt;&lt;br&gt;
Once the package is integrated, we’ll need to set up our Cloudinary object.&lt;br&gt;
Your API-Key and Cloud-Name will appear in the dashboard where you created your account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02muxtt06nej6dgm7n2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F02muxtt06nej6dgm7n2l.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Create the configuration object
let config = CLDConfiguration(cloudName: "CLOUD_NAME", apiKey: "API_KEY")
//Next we create the Cloudinary object
let cloudinary = CLDCloudinary(configuration: config)
view raw
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we have our Cloudinary object set and ready to use, this is where the &lt;strong&gt;MAGIC&lt;/strong&gt; starts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Upload your assets&lt;/strong&gt;&lt;br&gt;
There are multiple ways to upload an asset to your cloud, via the API or the UI&lt;br&gt;
UI — it’s as simple as dragging and dropping into your cloud.&lt;br&gt;
API — You can upload through the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let request = cloudinary
.createUploader()
.upload(url: file, uploadPreset: "sample_preset", params: CLDUploadRequestParams())
.response({
    (response, error) in
    // Handle response
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only thing we’re missing here is the upload preset. An upload preset is a field we need to set through the UI. You can do this by going to the Cloudinary &lt;a href="https://cloudinary.com/" rel="noopener noreferrer"&gt;website&lt;/a&gt;, signing in, and clicking the settings icon at the top right. Click the upload option, scroll down and add a new upload preset, There are many options to customize an upload preset but I’m not going to dive into them in this blog. Check out the &lt;a href="https://training.cloudinary.com/" rel="noopener noreferrer"&gt;Cloudinary Academy&lt;/a&gt; to learn more about what’s possible with Cloudinary’s APIs.&lt;/p&gt;

&lt;p&gt;Once the upload preset is created, be sure to put its name in the upload preset field in the uploadfunction. Yes, it’s as simple as that to upload an asset to your cloud, once the image is there we can start using transformations!&lt;br&gt;
Transformations are manipulations we can perform on an asset (image, video, etc…) there are many transformations and if you want to learn more than the examples I show here I suggest visiting Cloudinary’s &lt;a href="https://cloudinary.com/documentation/image_transformations" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transformations&lt;/strong&gt;&lt;br&gt;
At the start of this article, I presented the problem where we have one asset, but we need it in many different sizes and aspect ratios. Let’s see how we can achieve that very easily using Cloudinary’s transformations: (I’m going to use an asset called sample)&lt;/p&gt;

&lt;p&gt;The original image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5k1c8jpa9l9ae8hi0c6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5k1c8jpa9l9ae8hi0c6v.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Crop&lt;/strong&gt;&lt;br&gt;
We want to create a thumbnail(250x250) for our main screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let url = cloudinary.createUrl().setTransformation(
  CLDTransformation().setWidth(250).setHeight(250).setCrop(.crop))
.generate("sample")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me explain the code line above. We’re using the cloudinary object we created before, we call the createUrl() function and set a new transformation where we give all the parameters we want to modify in the image. Lastly, we call generate with the asset name (sample).&lt;br&gt;
This line of code will produce the following &lt;a href="https://res.cloudinary.com/test123/image/upload/c_crop,h_250,w_250/sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forw1yei2q0d60waqb1jc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Forw1yei2q0d60waqb1jc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see we got the 250x250 thumbnail we wanted, but the result could be improved. The “bee” which is the most interesting object in the image is cut off. What can we do? OH! Cloudinary has a few more tricks up its sleeve! Another COOL feature we can use “gravity” where we can ask Cloudinary to focus on the most interesting object in the image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gravity&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let url = cloudinary.createUrl().setTransformation(
  CLDTransformation().setWidth(250).setHeight(250).setCrop(.crop).setGravity(.auto))
.generate("sample")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output &lt;a href="https://res.cloudinary.com/test123/image/upload/c_crop,h_250,w_250,g_auto/sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrdc6604urfnmfc5qpmg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrdc6604urfnmfc5qpmg.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And as we can see the result is much better. The focus is on the bee.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quality&lt;/strong&gt;&lt;br&gt;
Let’s try another scenario. We have a 2k image, which is quite a large file, and we don't need it in its best form when we’re presenting it on the device. Roaming can’t always handle big bandwidth. To make the image lighter we can use the Cloudinary “quality” feature.&lt;/p&gt;

&lt;p&gt;Here’s the original image (it weighs 5MB which is quite a large file)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwp9plejt5fza7iyfxsc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flwp9plejt5fza7iyfxsc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Cloudinary we can do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let url = cloudinary.createUrl().setTransformation(
  CLDTransformation().setQuality(.auto()))
.generate("big_image_sample")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will produce the following &lt;a href="https://res.cloudinary.com/db0edm7to/image/upload/q_auto/big_image_sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbemrczusuqnjyokly866.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbemrczusuqnjyokly866.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it weighs 626.56 KB. We reduced the size by a lot, and it’ll be easier to get this image on a mobile device.&lt;/p&gt;

&lt;h2&gt;
  
  
  To sum up!
&lt;/h2&gt;

&lt;p&gt;As we saw in the blog, Cloudinary can answer the requirement to handle the same asset in many sizes and qualities. Not only that it has many other features! I encourage you to visit the &lt;a href="https://cloudinary.com/documentation/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; website to get the best out of the platform.&lt;/p&gt;

&lt;p&gt;The Cloudinary SDK can also be found on &lt;a href="https://github.com/cloudinary/cloudinary_android" rel="noopener noreferrer"&gt;Android&lt;/a&gt; and 14 more languages you can find at &lt;a href="https://github.com/cloudinary" rel="noopener noreferrer"&gt;Cloudinary’s git&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>mobile</category>
      <category>programming</category>
    </item>
    <item>
      <title>The best image format for mobile app</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Fri, 23 Dec 2022 20:10:49 +0000</pubDate>
      <link>https://dev.to/adimiz/the-best-image-format-for-mobile-app-4lp0</link>
      <guid>https://dev.to/adimiz/the-best-image-format-for-mobile-app-4lp0</guid>
      <description>&lt;p&gt;Throughout the years of app development (on both iOS and Android platforms), I ran into the same problem, what format should I use, what would be the optimal format for this OS (Android or iOS), that OS version, and the hardware that the device has, can it run what I’m building performance wise?&lt;br&gt;
I decided to write about this issue. In the following text, I will describe the various formats and how and when we could use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  iOS
&lt;/h2&gt;

&lt;p&gt;iOS 11+ — Since iOS 11, Apple has introduced a new iPhone photo format, &lt;code&gt;HEIC&lt;/code&gt; format for iOS devices. &lt;code&gt;HEIC&lt;/code&gt; is more efficient when it comes to file size while keeping the same image quality compared to &lt;code&gt;JPG&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;iOS 10 — Before iOS 11 the recommended image format was &lt;code&gt;PNG&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S3WbuXTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xewncbdh2zdtvtgq1jw8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S3WbuXTA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xewncbdh2zdtvtgq1jw8.png" alt="Image description" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HEIC vs PNG
&lt;/h2&gt;

&lt;p&gt;The new file format &lt;code&gt;HEIC&lt;/code&gt; stores images with smaller file sizes when you compare them to the common image file format i.e., &lt;code&gt;PNG&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Even though the size of the &lt;code&gt;HEIC&lt;/code&gt; image is smaller than the &lt;code&gt;PNG&lt;/code&gt; image file, the image quality is similar to the &lt;code&gt;PNG&lt;/code&gt; format.&lt;/p&gt;

&lt;p&gt;Compared to the &lt;code&gt;PNG&lt;/code&gt; file, the &lt;code&gt;HEIC&lt;/code&gt; file is far more flexible as it can store a single image or sequence of images. While on the other hand, the &lt;code&gt;PNG&lt;/code&gt; file can hold only one image.&lt;/p&gt;

&lt;p&gt;In addition to it, the &lt;code&gt;HEIC&lt;/code&gt; file contains an image, along with its metadata.&lt;/p&gt;

&lt;h2&gt;
  
  
  HEIC vs JPEG
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Compression&lt;/strong&gt;&lt;br&gt;
HEIC offers a much more efficient, modern compression method than the older JPEG format. HEIC breaks images into significantly smaller files without affecting quality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage space&lt;/strong&gt;&lt;br&gt;
Most HEIC files will take up significantly less room than JPEG on a computer, tablet, or smartphone.&lt;br&gt;
Their innovative compression process means HEIC can use as little as half the space that a JPEG file would.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image quality&lt;/strong&gt;&lt;br&gt;
When it comes to both compression and image quality, HEIC files win out over JPEG. The HEIC format can enhance the quality of photos with transparency and broader dynamic range capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compatibility&lt;/strong&gt;&lt;br&gt;
While JPEG has almost universal compatibility, HEIC files don't. HEIC has become more commonplace in recent years, but its primary use is on Apple devices. You may even need to convert your HEIC files to JPEG when transferring photos from an iPhone to a PC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transparency&lt;/strong&gt;&lt;br&gt;
HEIC supports image transparency in a similar way to PNG files, on the other hand, the JPEG format doesn't support transparency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extra Note
&lt;/h2&gt;

&lt;p&gt;But that’s not the end of it, on older devices that still support iOS 11 (iPhone 6 for example) &lt;code&gt;HEIC&lt;/code&gt; might still work but due to slow hardware, it might take a long time to render a &lt;code&gt;HEIC&lt;/code&gt; format image.&lt;br&gt;
This means that the iOS version is not the only parameter to determine the image format, it should also come from the device itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Android
&lt;/h2&gt;

&lt;p&gt;Android 4.2.1- — The recommended image format for the older Android version is &lt;code&gt;PNG&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Android 4.2.1 (API level 17)+ — Support for &lt;code&gt;webp&lt;/code&gt; was added.&lt;/p&gt;

&lt;p&gt;Android 12+ — Support for &lt;code&gt;AVIF&lt;/code&gt; was added on Android 12+.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h0rOulLt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkz4ij6jzg4fapqakknx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h0rOulLt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bkz4ij6jzg4fapqakknx.png" alt="Image description" width="880" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  WebP vs PNG
&lt;/h2&gt;

&lt;p&gt;This format provides superior lossless and lossy compression for images. Using &lt;code&gt;webp&lt;/code&gt;, developers can create smaller, richer images. &lt;code&gt;webp&lt;/code&gt; lossless image files are, on average, 26% smaller than PNG. These image files also support transparency (also known as alpha channel) at a cost of just 22% more bytes.&lt;br&gt;
&lt;code&gt;webp&lt;/code&gt; as a format can support both lossy and lossless modes, making it an ideal replacement for both &lt;code&gt;PNG&lt;/code&gt; and &lt;code&gt;JPG&lt;/code&gt;. The only thing to keep in mind is that it only has native support on devices running Android 4.2.1 (API level 17) and higher. Fortunately, most devices satisfy that requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  WebP vs JPEG
&lt;/h2&gt;

&lt;p&gt;According to this &lt;a href="https://developers.google.com/speed/webp/docs/webp_study"&gt;study&lt;/a&gt;, we see that the average &lt;code&gt;webp&lt;/code&gt; file size is 25%-34% smaller compared to &lt;code&gt;JPEG&lt;/code&gt; files, there results of the study indicate that &lt;code&gt;webp&lt;/code&gt; can provide significant compression improvements over &lt;code&gt;JPEG&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--npuUSky7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inx37yx92hgnocpdhfp4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--npuUSky7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inx37yx92hgnocpdhfp4.png" alt="Image description" width="880" height="658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;AVIF&lt;/code&gt; is a container format for images and sequences of images encoded using AV1. &lt;code&gt;AVIF&lt;/code&gt; takes advantage of the intra-frame encoded content from video compression. This dramatically improves image quality for the same file size when compared to older image formats, such as &lt;code&gt;JPEG&lt;/code&gt; or &lt;code&gt;PNG&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  AVIF vs PNG
&lt;/h2&gt;

&lt;p&gt;As a lossless compression file format, &lt;code&gt;PNG&lt;/code&gt; images are notorious for their large file sizes. &lt;code&gt;AVIF&lt;/code&gt; supports both lossy and lossless compression. It is this versatility that gives &lt;code&gt;AVIF&lt;/code&gt; an edge when it comes to file size.&lt;/p&gt;

&lt;p&gt;Decoding a &lt;code&gt;PNG&lt;/code&gt; is instant, thanks to the lack of complexity, AVIF tend to be more complex, therefore slower systems may struggle a bit more to decode the image.&lt;/p&gt;

&lt;p&gt;Currently, &lt;code&gt;PNG&lt;/code&gt; still holds is the best format for lossless compression with reduced file sizes and greater platform support. &lt;code&gt;AVIF&lt;/code&gt; is an excellent alternative for delivery if you’re willing to turn to lossy compression to reduce the file size, but comes with complexity that older platforms with old hardware may find challenging to render.&lt;/p&gt;

&lt;h2&gt;
  
  
  AVIF vs JPEG
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Quality&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;JPEG&lt;/code&gt; suffers in terms of compression quality today. Indeed, even the more modern &lt;code&gt;JPEG 2000&lt;/code&gt; can offer better overall compression.&lt;br&gt;
On the other hand &lt;code&gt;AVIF&lt;/code&gt; tends to provide some of the best results we can achieve with lossy, non-photographic images.&lt;br&gt;
Those who are dealing with an image with low fidelity &lt;code&gt;AVIF&lt;/code&gt; will out-perform &lt;code&gt;JPEG&lt;/code&gt; . But there are cons &lt;code&gt;AVIF&lt;/code&gt; as well, &lt;code&gt;AVIF&lt;/code&gt; image does not support progressive rendering, so files must be downloaded entirely before they can be displayed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Speed comparison&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;JPEG&lt;/code&gt; is outdated and was written before the invention of multicore CPU chips. It is not designed to work with a sequential process where there are multiple cores.&lt;br&gt;
&lt;code&gt;AVIF&lt;/code&gt; can work in parallel with multiple cores which makes it a more suitable form of image compression.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Animation&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;JPEG&lt;/code&gt; is an image format. This means that it was designed to show still images.&lt;br&gt;
&lt;code&gt;AVIF&lt;/code&gt; is based on an actual video codec and provides animation capacity which means it can support animations and &lt;code&gt;JPEG&lt;/code&gt; cannot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overall&lt;/strong&gt;&lt;br&gt;
Even though &lt;code&gt;JPEG 2000&lt;/code&gt; was a substantial improvement from the original &lt;code&gt;JPEG&lt;/code&gt; format it still cannot compete with &lt;code&gt;AVIF&lt;/code&gt; in many ways:&lt;br&gt;
&lt;code&gt;AVIF&lt;/code&gt; has become the ideal choice for those who need to manage encoding in a low-bandwidth setting, even though &lt;code&gt;JPEG&lt;/code&gt; supports progressive rendering it still lacks a lot of features that &lt;code&gt;AVIF&lt;/code&gt; offers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra note&lt;/strong&gt;&lt;br&gt;
Some devices with slow/old hardware might be able to get &lt;code&gt;AVIF&lt;/code&gt; or &lt;code&gt;webp&lt;/code&gt; based on their Android version but their hardware may fail to render those formats (due to low memory) or it could take a long time (due to a slow processor/ graphics processor).&lt;br&gt;
Same as iOS the Android optimal format can’t only be determined based on the Android version but we’ll have to consider the Android device as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Older Versions Format
&lt;/h2&gt;

&lt;h2&gt;
  
  
  PNG vs JPEG
&lt;/h2&gt;

&lt;p&gt;I want to raise another point here, for the older versions I did state that &lt;code&gt;PNG&lt;/code&gt; will be the optimal image format, but that’s not always true, &lt;code&gt;PNG&lt;/code&gt; vs &lt;code&gt;JPEG&lt;/code&gt; decision should be based on the complexity of the image and not solely on the platform they are running on.&lt;br&gt;
For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fKYp8VyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4cdl4s8k99xavkn1ugs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fKYp8VyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4cdl4s8k99xavkn1ugs.png" alt="Image description" width="618" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows two images that come out quite differently depending on which compression scheme the developer applies. The image on the left has many small details, and thus compresses more efficiently with &lt;code&gt;JPG&lt;/code&gt;. The image on the right, with runs of the same color, compresses more efficiently with &lt;code&gt;PNG&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to choose a format for Android?
&lt;/h2&gt;

&lt;p&gt;The following image provides a simple visualization to help you decide which compression scheme to use, one thing that should come into account, if the device supports Android 12+ you should consider (based on the restrictions I described here) using &lt;code&gt;AVIF&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D7_PpM5r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2h6rym44elsfgu6yobj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D7_PpM5r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2h6rym44elsfgu6yobj.png" alt="Image description" width="624" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to choose a format for iOS?
&lt;/h2&gt;

&lt;p&gt;Taking into account the restrictions I mentioned before, the decision should be pretty easy, iOS 11+ should always use &lt;code&gt;HEIC&lt;/code&gt; lower iOS version should go for &lt;code&gt;PNG&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Choosing an image format is no easy task, you must take into account a lot of parameters such as OS version, device, and image complexity.&lt;br&gt;
We can always choose the easy path and set &lt;code&gt;JPG&lt;/code&gt; to everything, but if we want better performance, better loading time, and overall better user experience we need to pick the correct format for each use-case.&lt;/p&gt;

&lt;p&gt;For further reading you can click the links below:&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format"&gt;HEIC&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/AVIF"&gt;AVIF&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/WebP"&gt;WebP&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ios</category>
      <category>android</category>
      <category>programming</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Xcode 14, It’s improving!</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Fri, 23 Dec 2022 19:57:26 +0000</pubDate>
      <link>https://dev.to/adimiz/xcode-14-its-improving-45om</link>
      <guid>https://dev.to/adimiz/xcode-14-its-improving-45om</guid>
      <description>&lt;p&gt;On the 12th of September Apple released the new Xcode version, Xcode 14.&lt;br&gt;
In this article, we’re going to discuss the changes and improvements that Apple put into its IDE.&lt;/p&gt;

&lt;h2&gt;
  
  
  Size matters
&lt;/h2&gt;

&lt;p&gt;Apple reduced the size of Xcode, compared to Xcode 13, Xcode 14 is 30% lighter.&lt;br&gt;
Xcode 13.4.1 weighs 10GB while Xcode 14.0 is 7.0GB, this is a big change since there were a lot of complaints from developers regarding Xcode size.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improved Auto-Completion
&lt;/h2&gt;

&lt;p&gt;An IDE that autocompletes when typing code is a great developer experience and a necessity for every developer.&lt;br&gt;
Xcode 14 is a great improvement from Xcode 13 when it comes to code completion.&lt;/p&gt;

&lt;p&gt;For example, Xcode will autocomplete a whole init function for you when you defined the class and the class members:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OGb73F6n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6s40ons1rhj9c96yhkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OGb73F6n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6s40ons1rhj9c96yhkm.png" alt="Image description" width="880" height="241"&gt;&lt;/a&gt;&lt;br&gt;
But that’s not the only new feature, this works also for objects that conform &lt;code&gt;Codable&lt;/code&gt; protocol, when you define the &lt;code&gt;init&lt;/code&gt; function the Xcode will suggest completing &lt;code&gt;init(from decoder: Decoder) {…}&lt;/code&gt; and will automatically autocomplete the entire function for you as you can see in the example below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6T4rSjpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sklh49zlv8ij8bbwuanv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6T4rSjpT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sklh49zlv8ij8bbwuanv.png" alt="Image description" width="880" height="251"&gt;&lt;/a&gt;&lt;br&gt;
And the result will be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GwZp-yy9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uu1fvz4fxkxw8u0n9fe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GwZp-yy9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uu1fvz4fxkxw8u0n9fe.png" alt="Image description" width="880" height="904"&gt;&lt;/a&gt;&lt;br&gt;
You can notice I also added the encode function, if you start typing encode Xcode will also autocomplete the entire function for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asset Catalog
&lt;/h2&gt;

&lt;p&gt;There are also improvements when it comes to the asset catalog, no more various app icon sizes, in Xcode 14 there is only 1024x1024:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vHeTEKN4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci6ql4efqzfvsf1ct1im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vHeTEKN4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci6ql4efqzfvsf1ct1im.png" alt="Image description" width="880" height="417"&gt;&lt;/a&gt;&lt;br&gt;
You can now double-click an image from the asset catalog to go to the file.&lt;/p&gt;

&lt;p&gt;You can also paste images directly from the clipboard to the asset catalog.&lt;/p&gt;

&lt;h2&gt;
  
  
  Improved Build Time
&lt;/h2&gt;

&lt;p&gt;More improvements are coming with the new Xcode version, this time it’ll save even more time.&lt;/p&gt;

&lt;p&gt;Build times have been improved significantly, with better parallelism algorithms that improved speed by x2, and projects' build time is 25% faster overall.&lt;br&gt;
The more cores you have on your Mac, the greater the improvement you’ll be seeing, Testing on the M1 Ultra studio showed an improvement of 30% in build time.&lt;/p&gt;

&lt;p&gt;And that’s not all, document loading improved by 50%, notarizing is 4x faster if you use the Interface Builder, and swapping between iPads and iPhones from the device bar is now 30% faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stronger and faster “Xcode Previews”
&lt;/h2&gt;

&lt;p&gt;When SwiftUI was introduced one of its key features was the “Xcode Previews”, this feature helps developers see all the UI changes in real-time side by side with the code.&lt;br&gt;
This means developers don't need to context switch, go back and forward to the UI, run the application on a simulator just to see what changed, and have a better development experience.&lt;br&gt;
The big change that Xcode 14 brings in is an interactive preview canvas, this means a developer can interact with the canvas (click a button, go between screens, etc).&lt;br&gt;
Xcode 14 comes with whole new specific controls that help the developer view the same UI in different orientations, schemes, or even dark mode, you can even see the same UI with different font sizes up to 12 screens at the same time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build Timeline
&lt;/h2&gt;

&lt;p&gt;In the previous versions of Xcode, we could only see build logs as one big list without much information about the steps, with Xcode 14 you can see exactly how much time each step took, and we can see a full timeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--f5VpCyY0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1swao5mgtzt8h2vgi52p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--f5VpCyY0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1swao5mgtzt8h2vgi52p.png" alt="Image description" width="880" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Simulator
&lt;/h2&gt;

&lt;p&gt;Xcode 14 also improved the simulator, it now supports remote notifications with iOS 16 simulators running on macOS 13 with Apple Silicon or T2 processors.&lt;/p&gt;

&lt;p&gt;With that said, the simulator will only support Apple Push Notification within the Sandbox environment.&lt;br&gt;
The APNS tokens will be a unique combination of both the Mac hardware and the simulator.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summarize
&lt;/h2&gt;

&lt;p&gt;Xcode 14 comes with various new features and improvements, faster coding (due to autocompletion), faster build time, improve simulator usage, and overall a better developer experience.&lt;/p&gt;

&lt;p&gt;If you would like to read the full release notes you can find them &lt;a href="https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>mobile</category>
      <category>programming</category>
      <category>swift</category>
    </item>
    <item>
      <title>Cloudinary with Flutter</title>
      <dc:creator>Adi Mizrahi</dc:creator>
      <pubDate>Thu, 22 Dec 2022 18:36:39 +0000</pubDate>
      <link>https://dev.to/adimiz/cloudinary-with-flutter-38a2</link>
      <guid>https://dev.to/adimiz/cloudinary-with-flutter-38a2</guid>
      <description>&lt;p&gt;As of late I've begun exploring different avenues regarding Google's Flutter framework.&lt;br&gt;
For the people who don't have the foggiest idea, Flutter is a cross-stage platform framework (Same as React Native) based on Dart programing language.&lt;/p&gt;

&lt;p&gt;After playing with the framework and understanding the best practices (thank you Effective Dart), I started to build our (Cloudinary’s) Flutter SDK.&lt;/p&gt;

&lt;p&gt;In the following article, I’ll explain why we decided to implement this SDK, how you can use it, and what good it will do for your application.&lt;/p&gt;
&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;One of the biggest pain points for a mobile developer is dealing with performance issues caused by handling many assets (images, videos, etc.) on multiple devices with different size screens.&lt;/p&gt;

&lt;p&gt;In one of my previous jobs, I was responsible for an application that allowed users to download images into their phones and set them as backgrounds for the home screen, lock screen, or both.&lt;br&gt;
This application required pulling big JSON files with all the image information, including multiple fields such as title, URL, created date, etc…&lt;br&gt;
On the main screen, I had to present a thumbnail (a small image representation of a larger image) of each image.&lt;br&gt;
Tapping a thumbnail would direct the user to a screen where the image was shown full screen.&lt;br&gt;
These 2 screens already required multiple versions of the same image. You can’t present a full-screen image as a thumbnail image because you’ll get a pixelated result which yields a bad user experience. On the other hand, we didn't want to present the full-screen image because that would cause a long load time for the screen, which is again a bad user experience.&lt;/p&gt;

&lt;p&gt;Moreover, every image came in a different size, so we had to find a way to present them uniformly.&lt;br&gt;
To add to the complexity, we wanted this app to work with different screen sizes (iPhones, iPads, different Android devices, and Android base tablets) which require different image sizes.&lt;br&gt;
The scenario in which we have a single image that needs to be displayed in many different sizes is very common. How can we best handle it? Let’s go through some possibilities.&lt;/p&gt;

&lt;p&gt;One solution would be to get it in one size for the client and manipulate it for our needs. Unfortunately, this solution wouldn't be efficient and could cause a long processing time.&lt;br&gt;
We could handle it on the server side (if we have one). We could create multiple URLs and send them to the client. But that would create big JSONS would be harder to handle and parse.&lt;/p&gt;

&lt;p&gt;That’s where Cloudinary comes in.&lt;/p&gt;
&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;What’s Cloudinary?&lt;br&gt;
Cloudinary is a platform that allows you to quickly and easily create, manage and deliver digital experiences across any browser, device, and bandwidth.&lt;/p&gt;

&lt;p&gt;Working with Cloudinary&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;The first thing you need to do is go to the Cloudinary website and sign-up for a free account.&lt;/p&gt;

&lt;p&gt;You can find the Git repository for the Cloudinary Flutter SDK here.&lt;/p&gt;

&lt;p&gt;To integrate Cloudinary into your app you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  cloudinary_flutter: ^0.0.1
  cloudinary_dart: ^0.0.7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;Once the package is integrated, we’ll need to set up our Cloudinary object.&lt;br&gt;
Your cloud name will appear in the dashboard where you created your account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyg8iobykehzx3slb2oe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyg8iobykehzx3slb2oe7.png" alt="Image description" width="700" height="191"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CloudinaryContext.cloudinary = Cloudinary.fromCloudName(cloudName: '&amp;lt;Cloud_name&amp;gt;');&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now that you have your Cloudinary object set and ready to use, the MAGIC starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transformations
&lt;/h2&gt;

&lt;p&gt;At the start of this article, I presented the problem where we have one asset, but we need it in many different sizes and aspect ratios. Let’s see how we can achieve that very easily by applying Cloudinary’s transformations.&lt;/p&gt;

&lt;p&gt;Here’s the original image called ‘dog’:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4e994yg09msrqbx63gt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4e994yg09msrqbx63gt.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Crop
&lt;/h2&gt;

&lt;p&gt;You can easily create a thumbnail(500x500) for your main screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = (CloudinaryContext.cloudinary.image('dog')
            ..transformation(Transformation()
              ..resize(Resize.crop()
                ..width(500)
                ..height(500))))
          .toString();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a new string URL using the Cloudinary object that was initiated in the previous step. The image function builds the URL using the publicId of the specified image.&lt;br&gt;
When calling transformation you can specify the action you want to perform. In this case, the resizeaction is applied with the Crop and the values for width and height , Finally, the toString()turns the object into a string.&lt;/p&gt;

&lt;p&gt;This code will output a URL for the following image:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvxkzh6r3znti16sbnxh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvxkzh6r3znti16sbnxh.png" alt="Image description" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see we got the 500x500 thumbnail we wanted, but the result could be improved. We lost the dog and we can only see white fur (not optimal at all).&lt;br&gt;
What can we do? OH! Cloudinary has a few more tricks up its sleeve! Another COOL feature we can use is “gravity” where we can ask Cloudinary to focus on the most interesting object in the image.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gravity
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = (CloudinaryContext.cloudinary.image('dog')
            ..transformation(Transformation()
              ..resize(Resize.crop()
                ..width(500)
                ..height(500)
                ..gravity(Gravity.autoGravity()))))
          .toString();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymp4wq9q5dadc1i0mm6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymp4wq9q5dadc1i0mm6u.png" alt="Image description" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And as we can see the result is much better. The focus is on the dog’s face.&lt;/p&gt;
&lt;h2&gt;
  
  
  Quality
&lt;/h2&gt;

&lt;p&gt;Let’s try another scenario. You want to deliver a 2k resolution image, which is quite a large file, and you don’t need to present it in its best form. Roaming can’t always handle big bandwidth. To make the image lighter we can use the Cloudinary “quality” feature.&lt;/p&gt;

&lt;p&gt;Here’s the original image (5MB)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9e9rjhw1y4qy75npufe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9e9rjhw1y4qy75npufe.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Cloudinary we can do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String url = (CloudinaryContext.cloudinary.image('dog')
             ..transformation(Transformation()
             ..delivery(Delivery.quality(Quality.auto))))
             .toString();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code will produce the following &lt;a href="https://res.cloudinary.com/db0edm7to/image/upload/q_auto/big_image_sample" rel="noopener noreferrer"&gt;URL&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45f9rbcgtihpqz4r4fm6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F45f9rbcgtihpqz4r4fm6.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this transformation, the size is reduced to 626.56 KB and it’ll be faster to load this image on a mobile device.&lt;/p&gt;

&lt;p&gt;Cloudinary’s Image Widget&lt;br&gt;
So far we’ve seen how to generate URLs and we can manually put them into an image widget, but Cloudinary gives us an extra zing, an image widget that can integrate with everything we’ve implemented so far.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CldImageWidget(
        publicId: 'dog',
        transformation: Transformation()
           ..resize(Resize.crop()
               ..width(500)
               ..height(500)
               ..gravity(Gravity.autoGravity()))
           ..delivery(Delivery.quality(Quality.auto)),
             ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code snippet above we see that we create the image widget and we give the following attributes:&lt;/p&gt;

&lt;p&gt;Public Id&lt;br&gt;
Resize crop, with width=500 and height=500 and Gravity auto&lt;br&gt;
Delivery with quality auto&lt;br&gt;
This code will generate the URLs we’ve seen before and will inject them into the image widget.&lt;/p&gt;

&lt;h2&gt;
  
  
  To sum up!
&lt;/h2&gt;

&lt;p&gt;In this blog, you saw how Cloudinary can handle the same asset in many sizes and qualities. That’s just the tip of the iceberg. Cloudinary has many other features that you can use when managing the media in your apps.&lt;br&gt;
I encourage you to visit Cloudinary’s documentation to get the most out of the platform.&lt;/p&gt;

&lt;p&gt;The Cloudinary SDK can also be found on Android and iOS and 14 more languages you can find at Cloudinary’s git.&lt;/p&gt;

</description>
      <category>security</category>
    </item>
  </channel>
</rss>
