<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0">
  <channel>
    <title>Cloudinary Blog</title>
    <link>https://cloudinary.com/blog</link>
    <description>Cloudinary is a SaaS that takes the hassle out of managing your websites images.</description>
    <language>en-us</language>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CloudinaryBlog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="cloudinaryblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>Getting Started with StencilJS</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:770px;"><div class="content-img-inner-wrapper" style="padding-top: 55.06%;"><img alt="StencilJS" src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/StecilJS_2000x1100.png" style="margin: 0 auto;display: block" title="StencilJS" /></div></div>
<a href="https://stenciljs.com" data-popup="true">StencilJS</a> is a new compiler for composing user interfaces using pure custom components. Stencil enables you to build components using new, cutting-edge technologies, such as TypeScript and JSX, then generates a pure <a href="http://robdodson.me/why-web-components/" data-popup="true">custom component</a> that can be used anywhere supported. This means you can import a Stencil generated component into React, Angular, Vue, etc.</p><a class="anchor" name="background"></a><h2><a href="#background">Background</a></h2><p>Stencil is basically a compiler, not necessarily a UI library. A compiler that transforms TSX (TypeScript + JSX) into self-contained custom components.</p><p>Before you start learning about the tool, it’s important to note that Stencil is not another heavy JavaScript framework you need to learn. If you have worked with Angular or React, or understand web components, then Stencil is worth a look.</p><p>Stencil enables you to write some TSX and SCSS, which it compiles down into shippable components. It was built by the Ionic team to help them write smaller, reusable components without having to carry along the weight of Angular. However, this led to solving a more general problem. We can write platform-independent component with our favorite tools (TS, JSX, etc) and compile to standard custom components which can then be used with any framework and supporting browsers.  All features of Stencil boil down to optimization and performance, which is the motivation behind Stencil.</p><p>Stencil also provides a lot of progressive features out of the box, including easy server-side rendering and service worker installation. Now let’s take a look at a practical approach to using Stencil and some of its interesting features.</p><a class="anchor" name="installing_stencil"></a><h2><a href="#installing_stencil">Installing Stencil</a></h2><p>Even Stencil’s installation is simple. You can clone a starter template from GitHub and install the npm dependencies. No major configuration, just clone, install and run.</p><p>Clone the repository from GitHub to your machine:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre># Clone starter
git clone https://github.com/ionic-team/stencil-starter.git todo</pre></div>
</div>
</div></div><p>Install the dependencies:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre># Enter the cloned project
cd todo

# Install dependencies
npm install</pre></div>
</div>
</div></div><p>You can start the app at port <code>3333</code> using the following command:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>npm start</pre></div>
</div>
</div></div><p>All our component code will be written in <code>src/components</code>. You can ignore the <code>my-name</code> starter component, since we will remove it from the face of the project.</p><a class="anchor" name="creating_components"></a><h2><a href="#creating_components">Creating Components</a></h2><p>Each component is saved in a containing folder, such as a TSX file. The containing folder also can contain an SCSS file for the component&#39;s styles. </p><p>Let&#39;s start with a container component that will serve as the app&#39;s shell. Create a folder named <code>site</code> in the <code>components</code> folder, then add <code>site.tsx</code> and <code>site.scss</code> files in the folder. You just created an empty Stencil component.</p><p>Throughout the article, we will skip the SCSS contents for brevity. You can grab them from the <a href="https://github.com/christiannwamba/stencil-gs" data-popup="true">GitHub repo provided</a>. With that in mind, let&#39;s add some component content:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// components/site/site.tsx</span>
<span style="color:#080;font-weight:bold">import</span> { Component } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>Component({
  <span style="color:#606">tag</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-site</span><span style="color:#710">'</span></span>,
  <span style="color:#606">styleUrl</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">site.scss</span><span style="color:#710">'</span></span>
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> Site {

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrapper</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;nav&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">container</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;h2&gt;</span>To - Do<span style="color:#070;font-weight:bold">&lt;/h2&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
        &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">nav&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;div class=&quot;container&quot;&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">          &lt;div class=&quot;row&quot;&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">            &lt;div class=&quot;col-md-offset-4 col-md-4 col-sm 12&quot;&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">                {</span><span style="color:#404">/</span></span>* Todo App goes here *<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">}</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808"></span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">            &lt;</span><span style="color:#404">/</span></span>div&gt;
          &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;</span><span style="color:#404">/</span></span>div&gt;
      &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">    );</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  }</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">}</span></span></pre></div>
</div>
</div></div>
<ul>
<li>The <code>Component</code> decorator - which is imported from <code>@stencil/core</code>  - defines a class as a component.</li>
<li>The <code>Site</code> class, which is decorated with the <code>Component</code> decorator, gets extended by the decorator to posses component features.</li>
<li>One of these features is having a tag, a style and a template. The tag and style is defined using an object and passing the object as argument to the decorator. The <code>render</code> method returns <a href="https://jsx.github.io/" data-popup="true">JSX</a>, which serves as the template for the component. This template is what gets rendered to the browser when the component is mounted.</li>
</ul>
<p>The tag is used to mount the component. In this case, replace <code>my-name</code> tag in <code>index.html</code> with the following:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;todo-site&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-site&gt;</span></pre></div>
</div>
</div></div><p>Then run the app using <code>npm start</code>. You should get the following:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 82.86%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/getting-started-with-stencil_jbni1b.png" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="composing_hierarchical_components"></a><h2><a href="#composing_hierarchical_components">Composing Hierarchical Components</a></h2><p>Just like every other scenario in which you used components, Stencil components can be composed with each other. This is the beauty of web components. A component can have multiple children and grandchildren, as well as siblings. This enables you to write small, self-contained components that can work with other smaller components and carry out a single task.</p><p>As an example, let&#39;s create another component called <code>TodoList</code> and compose with the <code>Site</code> component. The former will be a child component to the latter.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// components/todo-list/todo-list.tsx</span>
<span style="color:#080;font-weight:bold">import</span> { Component } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>Component({
  <span style="color:#606">tag</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-list</span><span style="color:#710">'</span></span>,
  <span style="color:#606">styleUrl</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-list.scss</span><span style="color:#710">'</span></span>
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> TodoList {

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">todo-list</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;ul&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;li&gt;</span>Write some code<span style="color:#070;font-weight:bold">&lt;/li&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;/ul&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
    );
  }
}</pre></div>
</div>
</div></div><p>Same syntax with the <code>Site</code> component, with different names and visuals. Let&#39;s now add the component to the parent <code>Site</code> component:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> Site {
  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrapper</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;nav&gt;</span>
          ...
        <span style="color:#070;font-weight:bold">&lt;/nav&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">container</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">row</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">col-md-offset-4 col-md-4 col-sm 12</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
              {/* Child component, TodoList */}
              <span style="color:#070;font-weight:bold">&lt;todo-list&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-list&gt;</span>

            <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
          &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;</span><span style="color:#404">/</span></span>div&gt;
      &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">    );</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  }</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">}</span></span></pre></div>
</div>
</div></div><p>We don&#39;t have to import the component child class to the parent class. We only need to include the <code>todo-list</code> tag and then Stencil looks up the component in the <code>components</code> folder and loads it accordingly.</p><a class="anchor" name="states_and_props"></a><h2><a href="#states_and_props">States and Props</a></h2><p>So far, we have just been dealing with static contents and markup. Most components you will write in Stencil will be useless if they do not handle dynamic contents and markup. States and Props decorators are used to bring life to Stencil components.</p><a class="anchor" name="states"></a><h3><a href="#states">States</a></h3><p>A state is a mutable chunk of data defined in a component. After initialization, it can be overwritten, deleted and updated to fit the needs of a component. A state is basically a class property decorated with the <code>State</code> decorator:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> { Component, State } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>Component({
  <span style="color:#606">tag</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-site</span><span style="color:#710">'</span></span>,
  <span style="color:#606">styleUrl</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">site.scss</span><span style="color:#710">'</span></span>
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> Site {

  <span style="color:#777">// todos as a state</span>
  <span style="color:#F00;background-color:#FAA">@</span>State() todos: Todo[] = [
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Cook</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">false</span>},
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Dance</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">true</span>},
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Eat</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">false</span>}
  ];

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrapper</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        ...
        <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">container</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">row</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">col-md-offset-4 col-md-4 col-sm 12</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
              <span style="color:#070;font-weight:bold">&lt;todo-list</span> <span style="color:#b48">todos</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.todos</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-list&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
          &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;</span><span style="color:#404">/</span></span>div&gt;
      &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">    );</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  }</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">}</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808"></span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">interface Todo {</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  task: string;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  completed: boolean;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">}</span></span></pre></div>
</div>
</div></div><p>The <code>todos</code> property is defined as a state and initialized with an array with three Todo objects. The object is typed as a <code>Todo</code> interface and has task (string) and completed (boolean) properties.</p><p>A state, unlike props, can be updated at runtime, which makes them mutable. In our case, for example, we can add or remove tasks.</p><p>The <code>todos</code> state is used in the component by passing it down to the <code>todo-list</code> component using props.</p><a class="anchor" name="props"></a><h3><a href="#props">Props</a></h3><p>Take another look on how we passed the array of todos to the <code>todo-list</code> component:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;todo-list</span> <span style="color:#b48">todos</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.todos</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-list&gt;</span></pre></div>
</div>
</div></div><p>The <code>todos</code> property, which is passed the array of todo items is what is referred to as <code>props</code>.</p><p>Before the <code>todo-list</code> component can receive values via <code>todos</code> props, it needs to be aware of the incoming values. In that case, we need to create a <code>todos</code> property on the component class and decorate the class using <code>Props</code>:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> { Component, Prop } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>Component({
  <span style="color:#606">tag</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-list</span><span style="color:#710">'</span></span>,
  <span style="color:#606">styleUrl</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-list.scss</span><span style="color:#710">'</span></span>
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> TodoList {

  <span style="color:#F00;background-color:#FAA">@</span>Prop() todos: Todo[];

  completedClass(todo: Todo) : string {
    <span style="color:#080;font-weight:bold">return</span> todo.completed ? <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">completed</span><span style="color:#710">'</span></span> : <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span>;
  }

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">todo-list</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;ul&gt;</span>
          {this.todos.map(todo =<span style="color:#F00;background-color:#FAA">&gt;</span> <span style="color:#070;font-weight:bold">&lt;li</span> <span style="color:#b48">class</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.completedClass</span><span style="color:#F00;background-color:#FAA">(</span><span style="color:#b48">todo</span><span style="color:#F00;background-color:#FAA">)</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#070;font-weight:bold">&gt;</span>{todo.task}<span style="color:#070;font-weight:bold">&lt;/li&gt;</span>)}
        <span style="color:#070;font-weight:bold">&lt;/ul&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
    );
  }
}

<span style="color:#080;font-weight:bold">interface</span> Todo {
  <span style="color:#606">task</span>: string;
  completed: <span style="color:#080;font-weight:bold">boolean</span>;
}</pre></div>
</div>
</div></div><p>The property is defined as an array and typed with the Todo interface, as well. When the component receives this value, we iterate over each of the items in the array using <code>map</code> and display them in a <code>li</code> tag. There is a also a <code>completedClass</code> method, which returns <code>completed</code> or empty string if the <code>completed</code> property of the each todo is <code>true</code> or <code>false</code> respectively.</p>
<blockquote>
<p>There is a major difference between states and props. States are mutable and can be changed at runtime, while props will always retain the value it received throughout runtime. Props also are received as attributes via the component&#39;s tag.</p></blockquote>
<a class="anchor" name="events_and_listeners"></a><h2><a href="#events_and_listeners">Events and Listeners</a></h2><p>Now we got the problem of dynamic content of the table, we need to worry about interaction. How do we create new tasks? What happens when each todo item is clicked? Let&#39;s answer those questions now.</p><p>An event is raised when a user interacts with your component. We can create and emit custom events for such interactions. Events are raised with Event Emitters and are decorated with the <code>Event</code> decorator.</p><p>Let&#39;s see some event logic by clicking on each item in the todo list:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> { Component, Event, EventEmitter, Prop } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> TodoList {

  <span style="color:#F00;background-color:#FAA">@</span>Prop() todos: Todo[];
  <span style="color:#F00;background-color:#FAA">@</span>Event() toggleTodo: EventEmitter;

  ...

  <span style="color:#777">// Event handler. Triggered by onClick</span>
  <span style="color:#777">// DOM event on the template in render()</span>
  handleToggleTodo(todo) {
    <span style="color:#950">this</span>.toggleTodo.emit(todo)
  }

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">todo-list</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;ul&gt;</span>
          {this.todos.map(todo =<span style="color:#F00;background-color:#FAA">&gt;</span> <span style="color:#070;font-weight:bold">&lt;li</span> <span style="color:#b48">class</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.completedClass</span><span style="color:#F00;background-color:#FAA">(</span><span style="color:#b48">todo</span><span style="color:#F00;background-color:#FAA">)</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#b48">onClick</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.handleToggleTodo.bind</span><span style="color:#F00;background-color:#FAA">(</span><span style="color:#b48">this</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">todo</span><span style="color:#F00;background-color:#FAA">)</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span>{todo.task}<span style="color:#070;font-weight:bold">&lt;/li&gt;</span>)}
        <span style="color:#070;font-weight:bold">&lt;/ul&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
    );
  }
}</pre></div>
</div>
</div></div><p>In the render method, you can see we have an <code>onClick</code> attribute attached to each <code>li</code> method in the <code>map</code> iteration. This attribute attaches a DOM event; a click event to be precise. </p><p>When this button is clicked, the <code>handleToggleTodo</code> method is called with the right context while passing the actual todo item that was clicked.</p><p>The <code>handleToggleTodo</code> method then emits a <strong>custom</strong> event. This custom event (<code>toggleTodo</code>) is decorated as <code>Event</code> and defined as <code>EventEmitter</code> type. Calling <code>emit</code> on the custom event triggers a global event that we can listen to from anywhere in the app.</p><p>We can head to the parent component (Site) and create a listener for the event:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> { Component, State, Listen } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;
...
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> Site {
  ...
  <span style="color:#F00;background-color:#FAA">@</span>Listen(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">toggleTodo</span><span style="color:#710">'</span></span>)
  toggleTodo(e): <span style="color:#080;font-weight:bold">void</span> {
    <span style="color:#777">// Retrieve event payload</span>
    <span style="color:#777">// from e.detail</span>
    const todo = e.detail;
    <span style="color:#950">this</span>.todos = <span style="color:#950">this</span>.todos.map(x =&gt; {
      <span style="color:#080;font-weight:bold">if</span> (x.task === todo.task) {
        const updated = {
          <span style="color:#606">task</span>: x.task,
          <span style="color:#606">completed</span>: !x.completed
        };
        <span style="color:#080;font-weight:bold">return</span> updated;
      }
      <span style="color:#080;font-weight:bold">return</span> x;
    })
  }
  ...
}</pre></div>
</div>
</div></div><p>The event listener is of course a decorated method. The method must be decorated with <code>Listener</code> and the decorator is passed the actual name of the emitter; in our case <code>toggleTodo</code>.</p>
<blockquote>
<p>The name of the method handling the event doesn&#39;t have to be the same as the event emitted. What is important is that the method is decorated and that the decorator is passed the name of the emitted event.</p></blockquote>
<p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 82.86%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-25_at_6.24.09_AM_vzbgkv.png" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="creating_new_todos"></a><h3><a href="#creating_new_todos">Creating New Todos</a></h3><p>You have learned so much about Stencil and Stencil components. Before we conclude, let&#39;s add another component that we can use to add more todo items to the todo list:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// components/todo-form/todo-form.tsx</span>
<span style="color:#080;font-weight:bold">import</span> { Component, Event, EventEmitter, State } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>Component({
  <span style="color:#606">tag</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-form</span><span style="color:#710">'</span></span>,
  <span style="color:#606">styleUrl</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">todo-form.scss</span><span style="color:#710">'</span></span>
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> TodoForm {

  <span style="color:#F00;background-color:#FAA">@</span>Event() newTodo: EventEmitter;
  <span style="color:#F00;background-color:#FAA">@</span>State() todo: string;


  handleChange(e) {
    <span style="color:#950">this</span>.todo = (e.target as HTMLTextAreaElement).value;
  }

  handleNewTodo() {
    <span style="color:#950">this</span>.newTodo.emit(<span style="color:#950">this</span>.todo);
    <span style="color:#950">this</span>.todo = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#710">'</span></span>;
  }

  render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">todo-form</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;input</span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">text</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">form-control</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">placeholder</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">New Task</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">value</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.todo</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#b48">onChange</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.handleChange.bind</span><span style="color:#F00;background-color:#FAA">(</span><span style="color:#b48">this</span><span style="color:#F00;background-color:#FAA">)</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#070;font-weight:bold">/&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;button</span> <span style="color:#b48">onClick</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.handleNewTodo.bind</span><span style="color:#F00;background-color:#FAA">(</span><span style="color:#b48">this</span><span style="color:#F00;background-color:#FAA">)</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span>Add<span style="color:#070;font-weight:bold">&lt;/button&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
    );
  }
}</pre></div>
</div>
</div></div><p>Not so much a big difference from what we have dealt with in previous sections. Here are the obvious additions:</p>
<ul>
<li>We have an internal state property (<code>todo</code>) that tracks the text being entered in the input field. When the value changes, we set the value of the state property to the new value of the input field.</li>
<li>There is a button that submits the current value of <code>todo</code> anytime the button is clicked. It does so by triggering a <code>handleNewTodo</code> method which in turn emits a <code>newTodo</code> custom event</li>
</ul>
<p>Back to the parent component, we can add a listener to update the list of todo items:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> { Component, State, Listen } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@stencil/core</span><span style="color:#710">'</span></span>;

<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> Site {
  <span style="color:#F00;background-color:#FAA">@</span>State() todos: Todo[] = [
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Cook</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">false</span>},
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Dance</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">true</span>},
    {<span style="color:#606">task</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Eat</span><span style="color:#710">'</span></span>, <span style="color:#606">completed</span>: <span style="color:#069">false</span>}
  ];

  <span style="color:#F00;background-color:#FAA">@</span>Listen(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">newTodo</span><span style="color:#710">'</span></span>)
  newTodo(e) {
    const newTodo = {
      <span style="color:#606">task</span>: e.detail,
      <span style="color:#606">completed</span>: <span style="color:#069">false</span>
    };
    <span style="color:#950">this</span>.todos = [...<span style="color:#950">this</span>.todos, newTodo];
  }
 ...
 render() {
    <span style="color:#080;font-weight:bold">return</span> (
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrapper</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        ...
        <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">container</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">row</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">col-md-offset-4 col-md-4 col-sm 12</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
              <span style="color:#070;font-weight:bold">&lt;todo-form&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-form&gt;</span>
              <span style="color:#070;font-weight:bold">&lt;todo-list</span> <span style="color:#b48">todos</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">this.todos</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span><span style="color:#070;font-weight:bold">&lt;/todo-list&gt;</span>
            <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
          &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;</span><span style="color:#404">/</span></span>div&gt;
      &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">div&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">    );</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">  }</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">}</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">...</span></span></pre></div>
</div>
</div></div>
<ul>
<li>The <code>newTodo</code> method, which handles the custom event, updates the list of todos with the new task we added.</li>
<li>We also added the form component in the render method: <code>&lt;todo-form&gt;&lt;/todo-form&gt;</code>.</li>
</ul>
<p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 82.86%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-25_at_6.45.20_AM_lrsizi.png" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>While we covered a lot of interesting Stencil concepts, there are many other features, such as routing, offline-first, SSR and more, to explore. As a matter of fact, to start building an offline experience, just run <code>npm build</code> to generate app builds with a service worker.</p><p>You can head right to the <a href="https://stenciljs.com/" data-popup="true">Stencil website</a> to learn more about these advanced features. Stencil has an <a href="https://stencil-worldwide.slack.com" data-popup="true">engaging Slack community</a> which you can be apart of to get help faster. You can also follow the <a href="https://twitter.com/stenciljs" data-popup="true">Stencil team on Twitter</a> to get updates on the tool.  You also can get the demo from the <a href="https://github.com/christiannwamba/stencil-gs" data-popup="true">Github repo</a> and play with the examples you saw in this article.</p><p><a href="https://cloudinary.com" data-popup="true">Cloudinary</a> enables you to manage (store, transform and deliver) media contents from the cloud. You can get started with the free plan that supports 300,000 images and videos and offload media assets management in your app to Cloudinary.</p><p>In the next post we will discuss how to <strong>Make a Video Web Component, the Stencil Way</strong> with Cloudinary!</p>]]>
      </description>
      <author />
      <pubDate>Mon, 20 Nov 2017 20:51:09 +0000</pubDate>
      <link>https://cloudinary.com/blog/getting_started_with_stenciljs</link>
      <guid>https://cloudinary.com/blog/getting_started_with_stenciljs</guid>
    </item>
    <item>
      <title>Easy Image Loading and Optimization with Cloudinary and Fresco</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:1540px;"><div class="content-img-inner-wrapper" style="padding-top: 70.32%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/loading-645268_1280.jpg" style="margin: 0 auto;display: block" /></div></div>
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/" data-popup="true">Cloudinary</a> and <a href="http://frescolib.org/" data-popup="true">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><p><div class="content-img-outer-wrapper" style="max-width:245px;"><div class="content-img-inner-wrapper" style="padding-top: 104.08%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/c_fill/dpr_auto/1_0hTcjWXj85prs7_VuVR9_g.gif" style="margin: 0 auto;display: block" /></div></div></p><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><a class="anchor" name="multiple_image_multi_uri_requests"></a><h2><a href="#multiple_image_multi_uri_requests">Multiple Image (Multi-URI) Requests</a></h2><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><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>Uri lowResUri, highResUri;
DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setLowResImageRequest(ImageRequest.fromUri(lowResUri))
                .setImageRequest(ImageRequest.fromUri(highResUri))
                .setOldController(mSimpleDraweeView.getController()).build();
mSimpleDraweeView.setController(controller);</pre></div>
</div>
</div></div><a class="anchor" name="but_how_i_can_generate_two_image_quality_uris"></a><h2><a href="#but_how_i_can_generate_two_image_quality_uris">But How I Can Generate Two Image Quality URIs?</a></h2><p>Cloudinary’s <a href="https://cloudinary.com/documentation/fetch_remote_images" data-popup="true">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><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 50.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/1_sANm3V13vN9SQRFGWHIerQ.png" style="margin: 0 auto;display: block" /></div></div>
<em>https://s3.amazonaws.com/myappmedia/donut.png</em></p><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><a class="anchor" name="fetching_remote_images_with_cloudinary"></a><h2><a href="#fetching_remote_images_with_cloudinary">Fetching Remote Images With Cloudinary</a></h2><p>Here’s the basic URL template for fetching any remote image with Cloudinary:</p><div class="code-holder"><div class="code_inner"><pre>https://res.cloudinary.com/&lt;cloud&gt;/image/fetch/&lt;transformations&gt;/&lt;remote_image_url&gt;</pre></div></div><a class="anchor" name="add_dynamic_transformations_for_low_resolution"></a><h2><a href="#add_dynamic_transformations_for_low_resolution">Add Dynamic Transformations For Low Resolution</a></h2><p>And here’s what the URL looks like when you add parameters that adjust the quality:</p><div class="code-holder"><div class="code_inner"><pre>http://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png</pre></div></div><p>This transformation converts the image (“<a href="http://cloudinary-res.cloudinary.com/image/upload/1_sANm3V13vN9SQRFGWHIerQ.png" data-popup="true">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><p><div class="example multi_code "><a class="anchor" name="api_example_1"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/fetch/f_auto,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/fetch/</span><span class="signature"></span><span class="trans">f_auto,q_auto:low,w_400/</span><span class="public_id">https://s3.amazonaws.com/myappmedia/donut.png</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:quality</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">400</span>, <span style="color:#A60">:fetch_format</span>=&gt;<span style="color:#A60">:auto</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:type</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">quality</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">400</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch_format</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">type</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>))</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>).image(quality=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, width=<span style="color:#00D">400</span>, fetch_format=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>, crop=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, type=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">fetch_format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">400</span>).fetchFormat(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">'</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">fetch_format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>}).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">fetch_format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">quality</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">400</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">fetch_format</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">quality</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">400</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">fetch_format</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.Transform(<span style="color:#080;font-weight:bold">new</span> Transformation().Quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">400</span>).FetchFormat(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).Type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:low</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">400</span>).fetchFormat(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto</span><span style="color:#710">&quot;</span></span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/fetch/f_auto,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:400px;"><div class="content-img-inner-wrapper" style="padding-top: 50.0%;"><img src="https://res.cloudinary.com/demo/image/fetch/f_auto,q_auto:low,w_400/https://s3.amazonaws.com/myappmedia/donut.png" style="margin: 0 auto;display: block" /></div></div></a></p>
<blockquote>
<p>Note that in order to work with WebP, the only thing you need to do is add the <code>webpsupport</code> library to your dependencies, like described <a href="http://frescolib.org/docs/webp-support.html" data-popup="true">here</a>.</p></blockquote>
<a class="anchor" name="add_dynamic_transformations_for_high_resolution"></a><h2><a href="#add_dynamic_transformations_for_high_resolution">Add Dynamic Transformations For High Resolution</a></h2><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><div class="code-holder"><div class="code_inner"><pre>http://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png</pre></div></div><p><div class="example multi_code "><a class="anchor" name="api_example_2"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/fetch/</span><span class="signature"></span><span class="trans">f_webp,q_auto:best,w_400/</span><span class="public_id">https://s3.amazonaws.com/myappmedia/donut.png</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:quality</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">400</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:format</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:type</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">quality</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">400</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">format</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">type</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>))</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>).image(quality=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, width=<span style="color:#00D">400</span>, crop=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, format=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, type=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">400</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).format(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>).type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">'</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>}).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">400</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">type</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">format</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">quality</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">400</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">format</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">quality</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">400</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.Transform(<span style="color:#080;font-weight:bold">new</span> Transformation().Quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">400</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).Format(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>).Type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().quality(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto:best</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">400</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>)).format(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">webp</span><span style="color:#710">&quot;</span></span>).type(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fetch</span><span style="color:#710">&quot;</span></span>).generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:400px;"><div class="content-img-inner-wrapper" style="padding-top: 50.0%;"><img src="https://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:best,w_400/https://s3.amazonaws.com/myappmedia/donut.png" style="margin: 0 auto;display: block" /></div></div></a></p><p>To complete the example using Fresco, you just need to set those URLs for the low and high versions:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#0a8;font-weight:bold">String</span> originalImageURL = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://s3.amazonaws.com/myappmedia/donut.png</span><span style="color:#710">&quot;</span></span>;
<span style="color:#0a8;font-weight:bold">String</span> lowResUri = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">http://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:low,w_400/e_blur:90/</span><span style="color:#710">&quot;</span></span> + originalImageURL;
<span style="color:#0a8;font-weight:bold">String</span> highResUri = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">http://res.cloudinary.com/demo/image/fetch/f_webp,q_auto:best,w_400/</span><span style="color:#710">&quot;</span></span> + originalImageURL;
DraweeController controller = Fresco.newDraweeControllerBuilder() .setLowResImageRequest(ImageRequest.fromUri(Uri.parse(low_res_url))) .setImageRequest(ImageRequest.fromUri(Uri.parse(high_res_url))) .setOldController(mSimpleDraweeView.getController()).build();
mSimpleDraweeView.setController(controller);</pre></div>
</div>
</div></div><a class="anchor" name="pretty_easy_right"></a><h2><a href="#pretty_easy_right">Pretty easy, right?</a></h2><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 comment below if you have any questions about this post or any other media optimization related issues.
In our next post we are going to talk about how to’ optimize video in your Android application, stay tuned!</p>]]>
      </description>
      <author />
      <pubDate>Wed, 15 Nov 2017 19:12:16 +0000</pubDate>
      <link>https://cloudinary.com/blog/easy_image_loading_and_optimization_with_cloudinary_and_fresco</link>
      <guid>https://cloudinary.com/blog/easy_image_loading_and_optimization_with_cloudinary_and_fresco</guid>
    </item>
    <item>
      <title>Offline First Masonry Grid Showcase with Vue</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:770px;"><div class="content-img-inner-wrapper" style="padding-top: 55.06%;"><img alt="Cover image" src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/VUE_grid.png" style="margin: 0 auto;display: block" title="Cover image" /></div></div></p><p>To keep your product revelant in the market, you should be building <a href="https://developers.google.com/web/fundamentals/getting-started/codelabs/your-first-pwapp/" data-popup="true">Progressive Web Apps (PWA)</a>. Consider these <a href="https://developers.google.com/web/showcase/" data-popup="true">testimonies</a> on conversion rates, provided by leading companies, such as Twitter, Forbes, AliExpress, Booking.com and others. This article doesn&#39;t go into background, history or principles surrounding PWA. Instead we want to show a practical approach to building a progressive web app using the Vue.js library.</p><p><strong>Here is a breakdown of the project we will be tackling</strong>:</p>
<ul>
<li>A masonry grid of images, shown as collections. The collector, and a description, is attributed to each image. This is what a masonry grid looks like:
<div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 105.57%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-14_at_4.25.11_PM_gzl07h.png" style="margin: 0 auto;display: block" /></div></div></li>
<li>An offline app showing the grid of images. The app will be built with Vue, a fast JavaScript framework for small- and large-scale apps.</li>
<li>Because PWA images need to be effectively optimized to enhance smooth user experience, we will  store and deliver them via <a href="http://cloudinary.com" data-popup="true">Cloudinary</a>, an end-to-end media management service.</li>
<li>Native app-like behavior when launched on supported mobile browsers.</li>
</ul>
<p>Let&#39;s get right to it!</p><a class="anchor" name="setting_up_vue_with_pwa_features"></a><h2><a href="#setting_up_vue_with_pwa_features">Setting up Vue with PWA Features</a></h2><p>A service worker is a background worker that runs independently in the browser. It doesn&#39;t make use of the main thread during execution. In fact, it&#39;s unaware of the DOM. Just JavaScript.</p><p>Utilizing the service worker simplifies the process of making an app run offline. Even though setting it up is simple, things can go really bad when it’s not done right. For this reason, a lot of community-driven utility tools exist to help scaffold a service worker with all the recommended configurations. Vue is not an exception.</p><p>Vue CLI has a community template that comes configured with a service worker. To create a new Vue app with this template, make sure you have the Vue CLI installed:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>npm install -g vue-cli</pre></div>
</div>
</div></div><p>Then run the following to initialize an app:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>vue init pwa offline-gallery</pre></div>
</div>
</div></div><p>The major difference is in the <code>build/webpack.prod.conf.js</code> file. Here is what one of the plugins configuration looks like:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// service worker caching</span>
<span style="color:#080;font-weight:bold">new</span> SWPrecacheWebpackPlugin({
  <span style="color:#606">cacheId</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">my-vue-app</span><span style="color:#710">'</span></span>,
  <span style="color:#606">filename</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">service-worker.js</span><span style="color:#710">'</span></span>,
  <span style="color:#606">staticFileGlobs</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/**/*.{js,html,css}</span><span style="color:#710">'</span></span>],
  <span style="color:#606">minify</span>: <span style="color:#069">true</span>,
  <span style="color:#606">stripPrefix</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/</span><span style="color:#710">'</span></span>
})</pre></div>
</div>
</div></div><p>The plugin generates a service worker file when we run the build command. The generated service worker caches all the files that match the glob expression in <code>staticFileGlobs</code>. </p><p>As you can see, it is matching all the files in the <code>dist</code> folder. This folder is also generated after running the build command. We will see it in action after building the example app.</p><a class="anchor" name="masonry_card_component"></a><h2><a href="#masonry_card_component">Masonry Card Component</a></h2><p>Each of the cards will have an image, the image collector and the image description. Create a <code>src/components/Card.vue</code> file with the following template:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;template&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">card</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">card-content</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
     <span style="color:#070;font-weight:bold">&lt;img</span> <span style="color:#b48">:src</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">collection.imageUrl</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">:alt</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">collection.collector</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
     <span style="color:#070;font-weight:bold">&lt;h4&gt;</span>{{collection.collector}}<span style="color:#070;font-weight:bold">&lt;/h4&gt;</span>
     <span style="color:#070;font-weight:bold">&lt;p&gt;</span>{{collection.description}}<span style="color:#070;font-weight:bold">&lt;/p&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/template&gt;</span></pre></div>
</div>
</div></div><p>The card expects a <code>collection</code> property from whatever parent it will have in the near future. To indicate that, add a Vue object with the <code>props</code> property:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;template&gt;</span>
...
<span style="color:#070;font-weight:bold">&lt;/template&gt;</span>
<span style="color:#070;font-weight:bold">&lt;script&gt;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">default</span> {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#606">props</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">collection</span><span style="color:#710">'</span></span>],</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#606">name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">card</span><span style="color:#710">'</span></span></span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">}</span>
<span style="color:#070;font-weight:bold">&lt;/script&gt;</span></pre></div>
</div>
</div></div><p>Then add a basic style to make the card pretty, with some hover animations:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;template&gt;</span>
 ...
<span style="color:#070;font-weight:bold">&lt;/template&gt;</span>

<span style="color:#070;font-weight:bold">&lt;script&gt;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">...</span>
<span style="color:#070;font-weight:bold">&lt;/script&gt;</span>

<span style="color:#070;font-weight:bold">&lt;style&gt;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#B06;font-weight:bold">.card</span> {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">background</span>: <span style="color:#0A0">#F5F5F5</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">padding</span>: <span style="color:#60E">10px</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">margin</span>: <span style="color:#60E">0</span> <span style="color:#60E">0</span> <span style="color:#60E">1em</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">width</span>: <span style="color:#60E">100%</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">cursor</span>: <span style="color:#088">pointer</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">transition</span>: <span style="color:#088">all</span> <span style="color:#60E">100</span><span style="color:#088">ms</span> <span style="color:#088">ease-in-out</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  }</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#B06;font-weight:bold">.card</span><span style="color:#00C;font-weight:bold">:hover</span> {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">transform</span>: <span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">l</span><span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">Y</span>(<span style="color:#60E">-0.5em</span>);</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">background</span>: <span style="color:#0A0">#EBEBEB</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  }</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#070;font-weight:bold">img</span> {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">display</span>: <span style="color:#088">block</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    <span style="color:#606">width</span>: <span style="color:#60E">100%</span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  }</span>
<span style="color:#070;font-weight:bold">&lt;/style&gt;</span></pre></div>
</div>
</div></div><a class="anchor" name="rendering_cards_with_images_stored_in_cloudinary"></a><h2><a href="#rendering_cards_with_images_stored_in_cloudinary">Rendering Cards with Images Stored in Cloudinary</a></h2><p><a href="https://cloudinary.com" data-popup="true">Cloudinary</a> is a web service that provides an end-to-end solution for managing media. Storage, delivery, transformation, optimization and more are all provided as one service by Cloudinary.</p><p>Cloudinary provides an <a href="http://cloudinary.com/documentation/upload_images" data-popup="true">upload API and widget</a>. But I already have some cool images stored on my Cloudinary server, so we can focus on delivering, transforming and optimizing them.</p><p>Create an array of JSON data in <code>src/db.json</code> with the content found <a href="https://github.com/christiannwamba/offline-masonry/blob/master/src/db.json" data-popup="true">here</a>. This is a truncated version of the file:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>[
  {
    <span style="color:#606"><span style="color:#404">&quot;</span><span>imageId</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">jorge-vasconez-364878_me6ao9</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>collector</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">John Brian</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>description</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Yikes invaluably thorough hello more some that neglectfully on badger crud inside mallard thus crud wildebeest pending much because therefore hippopotamus disbanded much.</span><span style="color:#710">&quot;</span></span>
  },
  {
    <span style="color:#606"><span style="color:#404">&quot;</span><span>imageId</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wynand-van-poortvliet-364366_gsvyby</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>collector</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Nnaemeka Ogbonnaya</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>description</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Inimically kookaburra furrowed impala jeering porcupine flaunting across following raccoon that woolly less gosh weirdly more fiendishly ahead magnificent calmly manta wow racy brought rabbit otter quiet wretched less brusquely wow inflexible abandoned jeepers.</span><span style="color:#710">&quot;</span></span>
  },
  {
    <span style="color:#606"><span style="color:#404">&quot;</span><span>imageId</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">josef-reckziegel-361544_qwxzuw</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>collector</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Ola Oluwa</span><span style="color:#710">&quot;</span></span>,
    <span style="color:#606"><span style="color:#404">&quot;</span><span>description</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">A together cowered the spacious much darn sorely punctiliously hence much less belched goodness however poutingly wow darn fed thought stretched this affectingly more outside waved mad ostrich erect however cuckoo thought.</span><span style="color:#710">&quot;</span></span>
  },
  <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
]</pre></div>
</div>
</div></div><p>The <code>imageId</code> field is the <code>public_id</code> of the image as assigned by the Cloudinary server, while <code>collector</code> and <code>description</code> are some random name and text respectively.</p><p>Next, import this data and consume it in your <code>src/App.vue</code> file:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> data from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./db.json</span><span style="color:#710">'</span></span>;

<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">default</span> {
  <span style="color:#606">name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">app</span><span style="color:#710">'</span></span>,
  data() {
    <span style="color:#080;font-weight:bold">return</span> {
      <span style="color:#606">collections</span>: []
    }
  },
  created() {
    <span style="color:#950">this</span>.collections = data.map(<span style="color:#950">this</span>.transform);
  }
}</pre></div>
</div>
</div></div><p>We added a property <code>collections</code> and we set it&#39;s value to the JSON data. We are calling a transform method on each of the items in the array using the <code>map</code> method.</p><a class="anchor" name="delivering_and_transforming_with_cloudinary"></a><h3><a href="#delivering_and_transforming_with_cloudinary">Delivering and Transforming with Cloudinary</a></h3><p>You can&#39;t display an image using it&#39;s Cloudinary ID. We need to give Cloudinary the ID so it can generate a valid URL for us. First, install Cloudinary:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>npm install --save cloudinary-core</pre></div>
</div>
</div></div><p>Import the SDK and configure it with your cloud name (as seen on Cloudinary dashboard):</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> data from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./db.json</span><span style="color:#710">'</span></span>;

<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">default</span> {
  <span style="color:#606">name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">app</span><span style="color:#710">'</span></span>,
  data() {
    <span style="color:#080;font-weight:bold">return</span> {
      <span style="color:#606">cloudinary</span>: <span style="color:#069">null</span>,
      <span style="color:#606">collections</span>: []
    }
  },
  created() {
    <span style="color:#950">this</span>.cloudinary = cloudinary.Cloudinary.<span style="color:#080;font-weight:bold">new</span>({
      <span style="color:#606">cloud_name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">christekh</span><span style="color:#710">'</span></span>
    })
    <span style="color:#950">this</span>.collections = data.map(<span style="color:#950">this</span>.transform);
  }
}</pre></div>
</div>
</div></div><p>The <code>new</code> method creates a Cloudinary instance that you can use to deliver and transform images. The <code>url</code> and <code>image</code> method takes the image public ID and returns a URL to the image or the URL in an image tag respectively:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">import</span> cloudinary from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">cloudinary-core</span><span style="color:#710">'</span></span>;
<span style="color:#080;font-weight:bold">import</span> data from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./db.json</span><span style="color:#710">'</span></span>;

<span style="color:#080;font-weight:bold">import</span> Card from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./components/Card</span><span style="color:#710">'</span></span>;

<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">default</span> {
  <span style="color:#606">name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">app</span><span style="color:#710">'</span></span>,
  data() {
    <span style="color:#080;font-weight:bold">return</span> {
      <span style="color:#606">cloudinary</span>: <span style="color:#069">null</span>,
      <span style="color:#606">collections</span>: []
    }
  },
  created() {
    <span style="color:#950">this</span>.cloudinary = cloudinary.Cloudinary.<span style="color:#080;font-weight:bold">new</span>({
      <span style="color:#606">cloud_name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">christekh</span><span style="color:#710">'</span></span>
    })
    <span style="color:#950">this</span>.collections = data.map(<span style="color:#950">this</span>.transform);
  },
  <span style="color:#606">methods</span>: {
    transform(collection) {
      const imageUrl =
        <span style="color:#950">this</span>.cloudinary.url(collection.imageId});
      <span style="color:#080;font-weight:bold">return</span> Object.assign(collection, { imageUrl });
    }
  }
}</pre></div>
</div>
</div></div><p>The transform method adds an imageUrl property to each of the image collections. The property is set to the URL received from the <code>url</code> method.</p><p>The images will be returned as is. No reduction in dimension or size. We need to use the Cloudinary transformation feature to customize the image:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>methods: {
  transform(collection) {
    const imageUrl =
      <span style="color:#950">this</span>.cloudinary.url(collection.imageId, { <span style="color:#606">width</span>: <span style="color:#00D">300</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fit</span><span style="color:#710">&quot;</span></span> });
    <span style="color:#080;font-weight:bold">return</span> Object.assign(collection, { imageUrl });
  }
},</pre></div>
</div>
</div></div><p>The <code>url</code> and <code>image</code> method takes a second argument, as seen above. This argument is an object and it is where you can customize your image properties and looks.</p><p>To display the cards in the browser, import the card component, declare it as a component in the Vue object, then add it to the template:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;template&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">app</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;header&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;span&gt;</span>Offline Masonary Gallery<span style="color:#070;font-weight:bold">&lt;/span&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;/header&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;main&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">wrapper</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;div</span> <span style="color:#b48">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cards</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
          <span style="color:#070;font-weight:bold">&lt;card</span> <span style="color:#b48">v-for</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">collection in collections</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">:key</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">collection.imageId</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">:collection</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">collection</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span><span style="color:#070;font-weight:bold">&lt;/card&gt;</span>
        <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
      <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;/main&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/div&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/template&gt;</span>

<span style="color:#070;font-weight:bold">&lt;script&gt;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">...</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="color:#080;font-weight:bold">import</span> Card from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">./components/Card</span><span style="color:#710">'</span></span>;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"></span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">default</span> {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#606">name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">app</span><span style="color:#710">'</span></span>,</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  data() {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    ...</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  },</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  created() {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    ...</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  },</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#606">methods</span>: {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">   ...</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  },</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  <span style="color:#606">components</span>: {</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">    Card</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">  }</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">}</span>
<span style="color:#070;font-weight:bold">&lt;/script&gt;</span></pre></div>
</div>
</div></div><p>We iterate over each card and list all the cards in the <code>.cards</code> element.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 105.29%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-14_at_9.50.45_PM_gm9er5.png" style="margin: 0 auto;display: block" /></div></div></p><p>Right now we just have a boring single column grid. Let&#39;s write some simple masonry styles.</p><a class="anchor" name="masonry_grid"></a><h3><a href="#masonry_grid">Masonry Grid</a></h3><p>To achieve the masonry grid, you need to add styles to both cards (parent) and card (child).</p><p>Adding column-count and column-gap properties to the parent kicks things up:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#B06;font-weight:bold">.cards</span> {
  <span style="color:#606">column-count</span>: <span style="color:#60E">1</span>;
  <span style="color:#606">column-gap</span>: <span style="color:#60E">1em</span>; 
}</pre></div>
</div>
</div></div><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 105.29%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-14_at_9.58.49_PM_ofu4xq.png" style="margin: 0 auto;display: block" /></div></div></p><p>We are close. Notice how the top cards seem cut off. Just adding <code>inline-block</code> to the <code>display</code> property of the child element fixes this:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">card</span> {
  <span style="color:#606">display</span>: <span style="color:#088">inline-block</span>
}</pre></div>
</div>
</div></div><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 105.57%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-14_at_4.25.11_PM_gzl07h.png" style="margin: 0 auto;display: block" /></div></div></p><p>If you consider adding animations to the cards, be careful as you will experience flickers while using the <code>transform</code> property. Assuming you have this simple transition on <code>.cards</code>:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#B06;font-weight:bold">.card</span> {
    <span style="color:#606">transition</span>: <span style="color:#088">all</span> <span style="color:#60E">100</span><span style="color:#088">ms</span> <span style="color:#088">ease-in-out</span>;
  }
  <span style="color:#B06;font-weight:bold">.card</span><span style="color:#00C;font-weight:bold">:hover</span> {
    <span style="color:#606">transform</span>: <span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">l</span><span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">Y</span>(<span style="color:#60E">-0.5em</span>);
    <span style="color:#606">background</span>: <span style="color:#0A0">#EBEBEB</span>;
  }</pre></div>
</div>
</div></div><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 104.29%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/masonry-flicker_m3zyjv.gif" style="margin: 0 auto;display: block" /></div></div></p><p>Setting perspective and backface-visibilty to the element fixes that:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#B06;font-weight:bold">.card</span> {
    <span style="color:#606">-webkit-perspective</span>: <span style="color:#60E">1000</span>;
    <span style="color:#606">-webkit-backface-visibility</span>: <span style="color:#088">hidden</span>; 
    <span style="color:#606">transition</span>: <span style="color:#088">all</span> <span style="color:#60E">100</span><span style="color:#088">ms</span> <span style="color:#088">ease-in-out</span>;
  }</pre></div>
</div>
</div></div><p>You also can account for screen sizes and make the grids responsive:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#088;font-weight:bold">@media</span> <span style="color:#339;font-weight:bold">only</span> <span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">c</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">n</span> <span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">d</span> (<span style="color:#F00;background-color:#FAA">m</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">-</span><span style="color:#F00;background-color:#FAA">w</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">d</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">h</span>: <span style="color:#60E">500px</span>) {
  <span style="color:#B06;font-weight:bold">.cards</span> {
    <span style="color:#606">column-count</span>: <span style="color:#60E">2</span>;
  }
}

<span style="color:#088;font-weight:bold">@media</span> <span style="color:#339;font-weight:bold">only</span> <span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">c</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">n</span> <span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">d</span> (<span style="color:#F00;background-color:#FAA">m</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">-</span><span style="color:#F00;background-color:#FAA">w</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">d</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">h</span>: <span style="color:#60E">700px</span>) {
  <span style="color:#B06;font-weight:bold">.cards</span> {
    <span style="color:#606">column-count</span>: <span style="color:#60E">3</span>;
  }
}

<span style="color:#088;font-weight:bold">@media</span> <span style="color:#339;font-weight:bold">only</span> <span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">c</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">n</span> <span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">d</span> (<span style="color:#F00;background-color:#FAA">m</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">-</span><span style="color:#F00;background-color:#FAA">w</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">d</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">h</span>: <span style="color:#60E">900px</span>) {
  <span style="color:#B06;font-weight:bold">.cards</span> {
    <span style="color:#606">column-count</span>: <span style="color:#60E">4</span>;
  }
}

<span style="color:#088;font-weight:bold">@media</span> <span style="color:#339;font-weight:bold">only</span> <span style="color:#F00;background-color:#FAA">s</span><span style="color:#F00;background-color:#FAA">c</span><span style="color:#F00;background-color:#FAA">r</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">e</span><span style="color:#F00;background-color:#FAA">n</span> <span style="color:#F00;background-color:#FAA">a</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">d</span> (<span style="color:#F00;background-color:#FAA">m</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">n</span><span style="color:#F00;background-color:#FAA">-</span><span style="color:#F00;background-color:#FAA">w</span><span style="color:#F00;background-color:#FAA">i</span><span style="color:#F00;background-color:#FAA">d</span><span style="color:#F00;background-color:#FAA">t</span><span style="color:#F00;background-color:#FAA">h</span>: <span style="color:#60E">1100px</span>) {
  <span style="color:#B06;font-weight:bold">.cards</span> {
    <span style="color:#606">column-count</span>: <span style="color:#60E">5</span>;
  }
}</pre></div>
</div>
</div></div><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 104.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/masonry2_h7xlb2.gif" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="optimizing_images"></a><h3><a href="#optimizing_images">Optimizing Images</a></h3><p>Cloudinary is already doing a great job by optimizing the size of the images after scaling them. You can optimize these images further, without losing quality while making your app much faster. </p><p>Set the <code>quality</code> property to <code>auto</code> while transforming the images. Cloudinary will find a perfect balance of size and quality for your app:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>transform(collection) {
const imageUrl =
   <span style="color:#777">// Optimize</span>
   <span style="color:#950">this</span>.cloudinary.url(collection.imageId, { <span style="color:#606">width</span>: <span style="color:#00D">300</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fit</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">auto</span><span style="color:#710">'</span></span> });
 <span style="color:#080;font-weight:bold">return</span> Object.assign(collection, { imageUrl });
}</pre></div>
</div>
</div></div><p>This is a picture showing the impact:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 53.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/cl-masonry-optimation_xdjjs1.png" style="margin: 0 auto;display: block" /></div></div></p><p>The first image was optimized from 31kb to 8kb, the second from 16kb to 6kb, and so on. Almost 1/4 of the initial size; about 75 percent. That&#39;s a huge gain. </p><p>Another screenshot of the app shows no loss in the quality of the images:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 64.86%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-14_at_10.45.14_PM_zo4dvc.png" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="making_the_app_work_offline"></a><h2><a href="#making_the_app_work_offline">Making the App Work Offline</a></h2><p>This is the most interesting aspect of this tutorial. Right now if we were to deploy, then go offline, we would get an error message. If you&#39;re using Chrome, you will see the popular dinosaur game.</p><p>Remember we already have service worker configured. Now all we need to do is to generate the service worker file when we run the build command. To do so, run the following in your terminal:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>npm run build</pre></div>
</div>
</div></div><p>Next, serve the generated build file (found in the the <code>dist</code> folder). There are lots of options for serving files on localhost, but my favorite still remains <code>serve</code>:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre># install serve
npm install -g serve

# serve
serve dist</pre></div>
</div>
</div></div><p>This will launch the app on localhost at port 5000. You would still see the page running as before. Open the developer tool, click the Application tab and select Service Workers. You should see a registered service worker:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 64.86%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-15_at_8.50.08_AM_djrchd.png" style="margin: 0 auto;display: block" /></div></div></p><p>The huge red box highlights the status of the registered service worker. As you can see, the status shows it&#39;s active. Now let&#39;s attempt going offline by clicking the check box in small red box. Reload the page and you should see our app runs offline:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 77.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-15_at_9.08.00_AM_d5gjoq.png" style="margin: 0 auto;display: block" /></div></div></p><p>The app runs, but the images are gone. Don&#39;t panic, there is a reasonable explanation for that. Take another look at the service worker config:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">new</span> SWPrecacheWebpackPlugin({
   <span style="color:#606">cacheId</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">my-vue-app</span><span style="color:#710">'</span></span>,
   <span style="color:#606">filename</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">service-worker.js</span><span style="color:#710">'</span></span>,
   <span style="color:#606">staticFileGlobs</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/**/*.{js,html,css}</span><span style="color:#710">'</span></span>],
   <span style="color:#606">minify</span>: <span style="color:#069">true</span>,
   <span style="color:#606">stripPrefix</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/</span><span style="color:#710">'</span></span>
 })</pre></div>
</div>
</div></div><p><code>staticFileGlobs</code> property is an array of local files we need to cache and we didn&#39;t tell the service worker to cache remote images from Cloudinary.</p><p>To cache remotely stored assets and resources, you need to make use of a different property called <code>runtimeCaching</code>. It&#39;s an array and takes an object that contains the URL pattern to be cached, as well as the caching strategy:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">new</span> SWPrecacheWebpackPlugin({
  <span style="color:#606">cacheId</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">my-vue-app</span><span style="color:#710">'</span></span>,
  <span style="color:#606">filename</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">service-worker.js</span><span style="color:#710">'</span></span>,
  <span style="color:#606">staticFileGlobs</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/**/*.{js,html,css}</span><span style="color:#710">'</span></span>],
  <span style="color:#606">runtimeCaching</span>: [
    {
      <span style="color:#606">urlPattern</span>: <span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">^https:</span><span style="color:#808">\/</span><span style="color:#808">\/</span><span style="color:#808">res</span><span style="color:#808">\.</span><span style="color:#808">cloudinary</span><span style="color:#808">\.</span><span style="color:#808">com</span><span style="color:#808">\/</span><span style="color:#404">/</span></span>,
      <span style="color:#606">handler</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">cacheFirst</span><span style="color:#710">'</span></span>
    }
  ],
  <span style="color:#606">minify</span>: <span style="color:#069">true</span>,
  <span style="color:#606">stripPrefix</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">dist/</span><span style="color:#710">'</span></span>
})</pre></div>
</div>
</div></div><p>Notice the URL pattern, we are using https rather than http. Service workers, for security reasons, only work with HTTPS, with localhost as exception. Therefore, make sure all your assets and resources are served over HTTPS. Cloudinary by default serves images over HTTP, so we need to update our transformation so it serves over HTTPS:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>const imageUrl =
        <span style="color:#950">this</span>.cloudinary.url(collection.imageId, { <span style="color:#606">width</span>: <span style="color:#00D">300</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fit</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">quality</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">auto</span><span style="color:#710">'</span></span>, <span style="color:#606">secure</span>: <span style="color:#069">true</span> });</pre></div>
</div>
</div></div><p>Setting the <code>secure</code> property to <code>true</code> does the trick. Now we can rebuild the app again, then try serving offline:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre># Build
npm run build

# Serve
serve dist</pre></div>
</div>
</div></div><p>Unregister the service worker from the developer tool, go offline, the reload. Now you have an offline app:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 79.71%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-09-15_at_9.27.47_AM_slgxen.png" style="margin: 0 auto;display: block" /></div></div></p><p>You can <a href="https://christiannwamba.github.io/offline-masonry/" data-popup="true">launch the app</a> on your phone, activate airplane mode, reload the page and see the app running offline.</p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>When your app is optimized and caters for users experiencing poor connectivity or no internet access, there is a high tendency of retaining users because you&#39;re keeping them engaged at all times. This is what PWA does for you. Keep in mind that a PWS must be characterized with optimized contents. Cloudinary takes care of that for you, as we saw in the article. You can <a href="https://cloudinary.com/users/register/free" data-popup="true">create a free account</a> to get started.</p><p><em>This post originally appeared on <a href="https://vuejsdevelopers.com/2017/10/09/vue-js-masonary-grid/" data-popup="true">VueJS Developers</a></em></p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="https://res.cloudinary.com/cloudinary/image/upload/c_thumb,w_100/christian_nwamba.jpg" alt="Christian Nwamba" title="Christian Nwamba"></img></td>
<td style = "padding: 10px;"><i><a href="https://twitter.com/codebeast" target="_new">Christian Nwamba</a>  (CodeBeast), is a JavaScript Preacher, Community Builder and Developer Evangelist.  In his next life, Chris hopes to remain a computer programmer.</i></td>
</tr>
</table>
]]>
      </description>
      <author>Christian Nwamba</author>
      <pubDate>Mon, 13 Nov 2017 19:26:30 +0000</pubDate>
      <link>https://cloudinary.com/blog/offline_first_masonry_grid_showcase_with_vue</link>
      <guid>https://cloudinary.com/blog/offline_first_masonry_grid_showcase_with_vue</guid>
    </item>
    <item>
      <title>Dynamic Image Manipulation and Optimization is eZ-er with the Novactive eZ Platform Cloudinary Connector</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:770px;"><div class="content-img-inner-wrapper" style="padding-top: 55.06%;"><img alt="Novactive eZ Platform integration with Cloudinary" src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/Connector_2000x1100.png" style="margin: 0 auto;display: block" title="Novactive eZ Platform integration with Cloudinary" /></div></div>
<em>(Guest post by <a href="https://www.linkedin.com/in/sebastienmorel/" data-popup="true">Sebastien Morel</a>)</em>
<br></p><a class="anchor" name="introduction"></a><h2><a href="#introduction">Introduction</a></h2><p>At Novactive, we are always excited to use new technologies and/or to improve our favorite technologies with other ones when it makes sense for us, for our clients and for the community.</p><p>Our business is web technologies, and the most professional content management system (CMS) for us is eZ Platform (previously eZ Publish). That&#39;s why we love creating connectors to this CMS. Our most recent eZ project is an image management plugin using Cloudinary.</p><p>If you are a web developer, whether or not you already use eZ Platform, Symfony, or Cloudinary, your website probably has some images, so take a look at what this cool connection can offer.</p><a class="anchor" name="ez_platform_quick_notes"></a><h2><a href="#ez_platform_quick_notes">eZ Platform Quick Notes</a></h2><p>If you aren&#39;t familiar with this CMS, you should have a look, but before we dive into the details about our Cloudinary integration, I just want to share in a few words the main reasons why I think <a href="https://ezplatform.com/" data-popup="true">eZ Platform</a> is the best PHP CMS:</p>
<ul>
<li><strong>Fully based on the Symfony PHP framework</strong>: eZ Platform is a Symfony application, as opposed to just using some Symfony components as others do. If you are a Symfony developer, you&#39;ll feel right at home.</li>
<li><strong>Decoupled CMS</strong>: eZ Platform separates the content creation process from the delivery process.</li>
<li><strong>Headless CMS</strong>: Thanks to the REST API, the presentation does not have to be handled by the CMS (but it can be)</li>
<li><strong>Mature</strong>: It&#39;s been around for more than 10 years.</li>
<li><strong>Supported</strong>: by <a href="https://ez.no" data-popup="true">eZ Systems</a></li>
</ul>
<a class="anchor" name="a_bit_about_cloudinary"></a><h2><a href="#a_bit_about_cloudinary">A Bit about Cloudinary</a></h2><p><a href="https://cloudinary.com/" data-popup="true">Cloudinary</a> is a cloud-based, end-to-end media management solution that automates and streamlines your entire media asset workflow. It <strong>removes all the hassles</strong> you would normally need to handle for your site’s <strong>images and videos</strong>, including <strong>responsiveness, compression, manipulations, hosting, caching, delivery</strong> and more!</p><p>The benefits of Cloudinary go way beyond this plugin and we can&#39;t possibly cover them all here. In this post, we are going to focus specifically on the eZ plugin offering, where our main goal was to let eZ Platform developers enjoy Cloudinary&#39;s powerful <strong>image optimization capabilities</strong> and provide easy access to all of Cloudinary&#39;s manipulation features, including:</p>
<ul>
<li>Advanced resizing</li>
<li>Smart detection-based cropping</li>
<li>Face detection</li>
<li>Instagram-like effects</li>
<li>Sprite and CSS generation</li>
<li>Transformation chaining</li>
</ul>
<p>For example, check out just some of what you can do just by specifying a few resizing and face-detection parameters:</p><p><div class="content-img-outer-wrapper" style="max-width:1220px;"><div class="content-img-inner-wrapper" style="padding-top: 79.67%;"><img alt="Cloudinary transformation examples resize and face detection" src="https://cloudinary-res.cloudinary.com/image/upload/eZ_Novactive_transformations.png" style="margin: 0 auto;display: block" title="Cloudinary transformation examples resize and face detection" /></div></div></p><p>For more examples of the available manipulations, take a look at Cloudinary&#39;s <a href="https://cloudinary.com/features/image_manipulation" data-popup="true">image manipulation gallery</a>, or the full list of all available options in the <a href="https://cloudinary.com/documentation/image_transformation_reference" data-popup="true">Cloudinary transformation reference.</a></p><p>By taking advantage of the Cloudinary plugin, you <strong>decouple</strong> your <strong>application</strong> a bit more, you get <strong>amazing manipulation features</strong> instantly, and automatic optimizations that will give a significant boost to your page load <strong>performance</strong>!</p><a class="anchor" name="motivation"></a><h2><a href="#motivation">Motivation</a></h2><p>“Content is king” in a web or a mobile project. You always need images or videos with your content.</p><p>Then you need to optimize them, store them in different adapted versions (known as variations), host them all, cache them and deliver them.</p><p>But you don’t want to reinvent the wheel. Plus image management is not likely your domain of expertise, so it&#39;s probably not the area where want to invest your time and resources. That&#39;s why we decided to create a plugin that can add Cloudinary on top of <strong>an existing eZ website</strong> smoothly, <strong>with almost no development required</strong>. </p><p>Our requirements for this <strong>M</strong>inimum <strong>V</strong>iable <strong>P</strong>lugin were:</p>
<ul>
<li>Using Cloudinary with <strong>no change on the architecture</strong></li>
<li><strong>No changes in the source code</strong></li>
<li><strong>Original images stay</strong> on the <strong>eZ Platform local environment</strong> (in case you want to stop using Cloudinary in the future)</li>
<li>The plugin should <strong>work on existing projects</strong> and <strong>provide</strong> Cloudinary’s <strong>manipulations</strong> and <strong>delivery features</strong></li>
</ul>
<p>So the requirements are simple in this <strong>MVP</strong>, and you still get to <strong>host the original image locally</strong>.</p><a class="anchor" name="ez_platform_default_image_handling"></a><h2><a href="#ez_platform_default_image_handling">eZ Platform Default Image Handling</a></h2><p>By default, eZ provides a concept of “variation” (previously known as “aliases”). This is a cool feature that many CMS still lack. It enables developers to make sure images are rendered in an optimized way in the various places they need to appear, for example: on a homepage at a certain size and on a detailed article page at a different size. This already helps prevents editors from loading super-heavy images directly into pages. But it&#39;s far from optimum and, as we will see, Cloudinary can do much better.  </p><p>By default, these image variations are generated with <a href="https://github.com/liip/LiipImagineBundle" data-popup="true">LiipImagineBundle</a>, using the underlying <a href="https://github.com/avalanche123/Imagine" data-popup="true">Imagine</a>. It supports GD, Imagick or Gmagick PHP extensions, and allows you to define a flexible filter to convert your original images into multiple “variations.”</p><p>eZ also abstracts the file system. By default, variations are stored on the file system, but you can configure it to store those images in an AWS S3 bucket if you wish. Obviously, they are generated only once and cleared on demand (e.g. content removal).</p><p>Here is an example of a variation definition:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>            <span style="color:#606">simple</span>:
                <span style="color:#606">reference</span>: ~
                <span style="color:#606">filters</span>:
                    - { <span style="color:#606">name</span>: auto_rotate }
                    - { <span style="color:#606">name</span>: geometry/scaledownonly, <span style="color:#606">params</span>: [<span style="color:#00D">128</span>,<span style="color:#00D">128</span>] }
                    - { <span style="color:#606">name</span>: strip }</pre></div>
</div>
</div></div><p>A more complex one:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>           <span style="color:#606">complex</span>:
                <span style="color:#606">reference</span>: ~
                <span style="color:#606">filters</span>:
                    - { <span style="color:#606">name</span>: auto_rotate }
                    - { <span style="color:#606">name</span>: geometry/scaledownonly, <span style="color:#606">params</span>: [<span style="color:#00D">326</span>,<span style="color:#00D">280</span>] }
                    - { <span style="color:#606">name</span>: geometry/crop, <span style="color:#606">params</span>: [<span style="color:#00D">326</span>, <span style="color:#00D">280</span>, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>] }
                    - { <span style="color:#606">name</span>: background, <span style="color:#606">params</span>: { <span style="color:#606">size</span>: [<span style="color:#00D">230</span>, <span style="color:#00D">144</span>], <span style="color:#606">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#FFFFFF</span><span style="color:#710">'</span></span> } }
                    - { <span style="color:#606">name</span>: strip }</pre></div>
</div>
</div></div><p>This is a great start, but it&#39;s not enough, as your servers still need to manage the conversion, storage, delivery and caching.
You are also limited to the PHP extension capabilities and the delivery capabilities of your servers/tools. And of-course you are lacking all the sophisticated manipulation features that a service like Cloudinary can provide.</p><a class="anchor" name="benefits_of_the_mvp"></a><h2><a href="#benefits_of_the_mvp">Benefits of the MVP</a></h2><p>The plugin will give you the ability to create variations based on Cloudinary features.
In other words, <strong>every manipulation feature available in Cloudinary will be yours as soon as you finish the plugin installation</strong>.</p><p>There is no code to change, just the variations to define, and if you don’t define them, the plugin will fallback to the standard handling.</p><p>Example of a Cloudinary variation:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>            <span style="color:#606">case</span>:
                <span style="color:#606">ezreference_variation</span>: ~
                <span style="color:#606">filters</span>:
                    <span style="color:#606">width</span>: <span style="color:#00D">710</span>
                    <span style="color:#606">width</span>: <span style="color:#00D">428</span>
                    <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">fit</span><span style="color:#710">'</span></span>
                    <span style="color:#606">fetch_format</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">auto</span><span style="color:#710">'</span></span>
                    <span style="color:#606">effect</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brightness:200</span><span style="color:#710">&quot;</span></span>
                    <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">max</span><span style="color:#710">'</span></span></pre></div>
</div>
</div></div><p>And the &quot;<strong>filters</strong>&quot; key enables you to use the <a href="https://cloudinary.com/documentation/image_transformations" data-popup="true">hundreds of possibilities</a> and combinations provided by Cloudinary.</p><p>Plus:</p>
<ul>
<li>Images are automatically served through Cloudinary’s servers, and every image is optimized to deliver the best possible quality at the smallest possible file size based on the content of the image and the specific browser that each customer uses to view your content. </li>
<li>No computation is done on your servers to convert images.</li>
</ul>
<a class="anchor" name="how_to_install_the_plugin"></a><h2><a href="#how_to_install_the_plugin">How to Install the Plugin</a></h2><p>The package is open source and available on our Github here: <a href="https://github.com/Novactive/NovaeZCloudinaryBundle" data-popup="true">https://github.com/Novactive/NovaeZCloudinaryBundle.</a></p><p>1) The installation is quite standard, using composer.</p><div class="code-holder"><div class="code_inner"><pre>$ composer require novactive/ezcloudinarybundle</pre></div></div><p>2) Register the bundle in your Kernel.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre> <span style="color:#080;font-weight:bold">public</span> <span style="color:#080;font-weight:bold">function</span> <span style="color:#06B;font-weight:bold">registerBundles</span>()
{
   ...
   <span style="color:#950">$bundles</span> = <span style="color:#369;font-weight:bold">array</span>(
       <span style="color:#080;font-weight:bold">new</span> <span style="color:#036;font-weight:bold">FrameworkBundle</span>(),
       ...
       <span style="color:#080;font-weight:bold">new</span> <span style="color:#036;font-weight:bold">Novactive</span>\<span style="color:#036;font-weight:bold">Bundle</span>\eZCloudinaryBundle\<span style="color:#036;font-weight:bold">NovaeZCloudinaryBundle</span>(),
   );
   ...
}</pre></div>
</div>
</div></div><p>3) Set up your credentials.
If you have not already done so, create a <a href="https://cloudinary.com/users/register/free" data-popup="true">Cloudinary account</a>. You can find your account credentials in the Cloudinary management console.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre> <span style="color:#606">nova_ezcloudinary</span>:
    <span style="color:#606">authentification</span>:
        <span style="color:#606">cloud_name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">xxx</span><span style="color:#710">&quot;</span></span>
        <span style="color:#606">api_key</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">xxxxx</span><span style="color:#710">&quot;</span></span>
        <span style="color:#606">api_secret</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">xxxx</span><span style="color:#710">&quot;</span></span></pre></div>
</div>
</div></div><p>4) Set up variation templates:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre> <span style="color:#606">system</span>:
    <span style="color:#606">default</span>:
        <span style="color:#606">cloudinary_variations</span>:
            <span style="color:#606">simpletest1</span>:
                <span style="color:#606">ezreference_variation</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Native eZ Variation Name, ~ means original</span><span style="color:#710">'</span></span>
                <span style="color:#606">filters</span>: 
                <span style="color:#777"># See Cloudinary documentation for available transformations:</span>
                    <span style="color:#606">width</span>: <span style="color:#00D">200</span>
                    <span style="color:#606">height</span>: <span style="color:#00D">200</span>
                    <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">face</span><span style="color:#710">'</span></span>
                    <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">max</span><span style="color:#710">'</span></span>
                    <span style="color:#606">effect</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">sepia</span><span style="color:#710">'</span></span></pre></div>
</div>
</div></div><p>5) Usage</p><p><strong>NOTHING!</strong> That is another part of the beauty of eZ Platform. 
Your current template code should look like this:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>     {{ ez_render_field( content, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">image</span><span style="color:#710">&quot;</span></span>,{
        <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">parameters</span><span style="color:#710">&quot;</span></span>: {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">alias</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">simpletest1</span><span style="color:#710">'</span></span>},
        <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">attr</span><span style="color:#710">&quot;</span></span> : { <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">class</span><span style="color:#710">&quot;</span></span> : <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">img-responsive</span><span style="color:#710">&quot;</span></span> }
    }
    ) }}</pre></div>
</div>
</div></div><p>At this point, the plugin automatically takes over and the function <code>nova_ezcloudinary_alias</code> will be used instead of <code>ez_image_alias</code>. The bundle falls back on the native variation system if the alias name does not exist in <code>cloudinary_variations</code>.</p><p>So basically there is no change in your code, just a <code>yaml</code> configuration for your variations.</p><a class="anchor" name="how_does_it_work"></a><h2><a href="#how_does_it_work">How Does it Work?</a></h2><p>The MVP uses the Cloudinary <a href="https://cloudinary.com/documentation/fetch_remote_images" data-popup="true">fetch</a> feature:</p><p>The <code>nova_ezcloudinary_alias</code> will change the source of the image (at rendering) and generate a URL such as:</p><p><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/fetch/c_fill,f_auto,g_auto,h_250,w_376/http://www.yourwebsite.com/var/site/storage/images/7/5/8/0/857-1-fre-FR/20140708_120625.jpg" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/fetch/</span><span class="signature"></span><span class="trans">c_fill,f_auto,g_auto,h_250,w_376/</span><span class="public_id">http://www.yourwebsite.com/var/site/storage/images/7/5/8/0/857-1-fre-FR/20140708_120625.jpg</span></a></span></div></div></p><p><strong>Note</strong>: Cloudinary also offers a personalized CNAME URL adapted to your own domain option (High tier plans).</p><p>The first time the image is requested, Cloudinary automatically fetches the original image from your eZ storage, stores it in a relative path in your Cloudinary account, and then performs the requested manipulations so that all the variations are then hosted by Cloudinary and served via CDN.</p><a class="anchor" name="dynamic_responsive_images"></a><h2><a href="#dynamic_responsive_images">Dynamic Responsive Images</a></h2><p>Once you have Cloudinary at your service, you can use its capabilities to more easily deliver responsive images. There are three ways to do this:</p>
<ol>
<li><p><strong>Dynamic image manipulation</strong> - Use Cloudinary to generate transformed versions of images. Then use the HTML srcset attribute, enabling the browser to choose which image versions to display based on the device hosting the browser.</p></li>
<li><p><strong>Automating responsive images with JavaScript (client side)</strong> - Programmatically set the &lt;img&gt; src URL.</p></li>
<li><p><strong>Automating responsive images with Client Hints (server side)</strong> - Deliver the optimal image based on the available width reported in the Client Hints request header. But this is not available on all browsers.</p></li>
</ol>
<p>We usually go with the <code>src</code> and <code>srcset</code> attribute of the &lt;img&gt; HTML tag as it does not require Javascript.</p><p>Simply speaking, <code>srcset</code> provides to the browser a set of URLs (variations) to use depending on the viewport size. The browser takes the information, combines them with the window width and screen density it already knows and does its job!</p><p>To exploit this feature with eZ, you just have to override the <code>ezimage</code> template to make it even more dynamic, using the following two steps:</p>
<ol>
<li>Create variations for each size:

<ul>
<li>myvariationname</li>
<li>myvariationname_1x</li>
<li>myvariationname_2x</li>
<li>myvariationname_3x</li>
</ul></li>
<li>Change the template that renders images, and adapt. </li>
</ol>
<p>Here&#39;s the code:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>{% block ezimage_field %}
    {% spaceless %}
        {% <span style="color:#080;font-weight:bold">if</span> not ez_is_field_empty( content, field ) %}
            {% set aliasName = parameters.alias|<span style="color:#080;font-weight:bold">default</span>( <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">original</span><span style="color:#710">'</span></span> ) %}
            {% set imageAlias = nova_ezcloudinary_alias( field, versionInfo, aliasName ) %}
            {% set src = imageAlias ? asset( imageAlias.uri ) : <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">//:0</span><span style="color:#710">&quot;</span></span> %}
            {% set width = parameters.width is <span style="color:#369;font-weight:bold">defined</span> ? parameters.width : imageAlias.width %}
            {% set height = parameters.height is <span style="color:#369;font-weight:bold">defined</span> ? parameters.height : imageAlias.height %}

            {% <span style="color:#080;font-weight:bold">if</span> aliasName == <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">original</span><span style="color:#710">'</span></span> %}
                {% set densities = [] %}
                {% set densitiesSizes = [] %}
            {% <span style="color:#080;font-weight:bold">else</span> %}
                {% set densities = [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1x</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">2x</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">3x</span><span style="color:#710">'</span></span>] %}
                {% set densitiesSizes = [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">640w</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1040w</span><span style="color:#710">'</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">1560w</span><span style="color:#710">'</span></span>] %}
            {% <span style="color:#080;font-weight:bold">endif</span> %}

            &lt;img {{ block( <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">field_attributes</span><span style="color:#710">'</span></span> ) }}
                    src=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> src }}</span><span style="color:#710">&quot;</span></span>{% <span style="color:#080;font-weight:bold">if</span> width %}
                    width=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> width }}</span><span style="color:#710">&quot;</span></span>{% <span style="color:#080;font-weight:bold">endif</span> %}{% <span style="color:#080;font-weight:bold">if</span> height %}
                    height=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> height }}</span><span style="color:#710">&quot;</span></span>{% <span style="color:#080;font-weight:bold">endif</span> %}
                    alt=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> field.value.alternativeText }}</span><span style="color:#710">&quot;</span></span>{% <span style="color:#080;font-weight:bold">if</span> parameters.<span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">is</span> <span style="color:#369;font-weight:bold">defined</span> <span style="color:#080;font-weight:bold">and</span> parameters.<span style="color:#080;font-weight:bold">class</span> <span style="color:#B06;font-weight:bold">is</span> not <span style="color:#369;font-weight:bold">empty</span> %}
                    <span style="color:#080;font-weight:bold">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> parameters.class }}</span><span style="color:#710">&quot;</span></span>{% <span style="color:#080;font-weight:bold">endif</span> %}
                    {% <span style="color:#080;font-weight:bold">if</span> densities|length &gt; <span style="color:#00D">0</span> %}
                        srcset=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{</span><span style="color:#D20">% for density in densities %}</span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> ez_image_alias( field, versionInfo, parameters.alias~'_'~density ).uri }} </span><span style="color:#D20">{</span><span style="color:#D20">{</span><span style="color:#D20"> densitiesSizes[loop.index0] }}</span><span style="color:#D20">{</span><span style="color:#D20">% if not loop.last %},</span><span style="color:#D20">{</span><span style="color:#D20">% endif %}</span><span style="color:#D20">{</span><span style="color:#D20">% endfor %}</span><span style="color:#710">&quot;</span></span>
                    {% <span style="color:#080;font-weight:bold">endif</span> %}
            /&gt;
        {% <span style="color:#080;font-weight:bold">endif</span> %}
    {% endspaceless %}
{% endblock %}</pre></div>
</div>
</div></div><p>With the above, you will end up with a generated HTML something like this:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>         &lt;img <span style="color:#080;font-weight:bold">class</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ezimage-field</span><span style="color:#710">&quot;</span></span>
                src=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">https://cloudinaryURL_for_myvariationname”</span></span>
<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#D20">               srcset=</span><span style="color:#710">&quot;</span></span>
https:<span style="color:#777">//cloudinaryURL_for_myvariationname_1px 640w,</span>
https:<span style="color:#777">//cloudinaryURL_for_myvariationname_2px 1040w,</span>
https:<span style="color:#777">//cloudinaryURL_for_myvariationname_3px 1560w&quot;</span>
/&gt;</pre></div>
</div>
</div></div><p>That&#39;s it! If you want to know more about <code>srcset</code> and <code>sizes</code>, check out this great <a href="https://blog.ycombinator.com/how-to-use-responsive-images/" data-popup="true">ycombinator responsive images</a> article.</p><a class="anchor" name="what_s_next"></a><h2><a href="#what_s_next">What&#39;s Next?</a></h2><p>What&#39;s Next? Well, that&#39;s for you to determine. We invite you to create a <a href="https://cloudinary.com/users/register/free" data-popup="true">free Cloudinary account</a>, install the plugin, and start to play with the images on your eZ site. 
We have a lot of big ideas for the next versions of this initial eZ-Cloudinary MVP, but first and foremost, we want to hear your ideas and see where you take it.</p><p>You are all welcome to contribute!</p><a class="anchor" name="about_novactive"></a><h2><a href="#about_novactive">About Novactive</a></h2><p><a href="http://www.novactive.us" data-popup="true">Novactive (Nextedia Group)</a> is a web agency that develops digital platforms. Founded in 1996, Novactive is the brainchild of several web aficionados, whose combined vision of integrity and purpose drives every business decision. In 2016, Novactive joined the <a href="http://www.nextedia.com/" data-popup="true">Nextedia Group</a>. Today Novactive with Nextedia is comprised of a highly experienced multidisciplinary team with more than 200 digital experts based in Paris, Toulon and San Francisco. </p><p><img src="http://cloudinary-res.cloudinary.com/image/upload/w_100,f_auto/Sebastien_Morel.jpg" alt="Sébastien Morel Novactive CTO, head of U.S. operations and technology" title="Sébastien Morel Novactive CTO, head of U.S. operations and technology" style="float:left; margin-right:15px; margin-top: 10px;">
<a href="https://www.linkedin.com/in/sebastienmorel/" data-popup="true">Sébastien Morel</a> is the CTO of Novactive, head of U.S. operations and technology, and runs the California office. Sébastien has been with the group for over 14 years.
“I love to take different web technologies and mix them together to get the best of them for our clients, but also to improve the developer and user experience. Open sourcing MVPs and packages is part of our core values. Sharing best practices and implementations, and allowing others to participate is THE way to build quality.”</p><p>Novactive are part of Cloudinary&#39;s partnership network. We at Cloudinary value our partners. If you are interested to become a Cloudinary partner check out our <a href="https://cloudinary.com/partners" data-popup="true">partnership program</a>. </p>]]>
      </description>
      <author>Sebastien Morel</author>
      <pubDate>Wed, 08 Nov 2017 17:43:16 +0000</pubDate>
      <link>https://cloudinary.com/blog/dynamic_image_manipulation_and_optimization_is_ez_er_with_the_novactive_ez_platform_cloudinary_connector1</link>
      <guid>https://cloudinary.com/blog/dynamic_image_manipulation_and_optimization_is_ez_er_with_the_novactive_ez_platform_cloudinary_connector1</guid>
    </item>
    <item>
      <title>Are your website images ready to embrace the iPhone X notch?</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:770px;"><div class="content-img-inner-wrapper" style="padding-top: 66.62%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/iPhone_X_Cover.jpg" style="margin: 0 auto;display: block" /></div></div></p><p>The announcement of the iPhone 8, 8 plus and the iPhone X at the iPhone 10th anniversary Apple event on 12th September 2017, came with a massive buzz. </p><p>The iPhone X (pronounced &quot;iPhone 10&quot;) has a 5.8-inch super retina screen, which stands out amongst other  Apples, giving the <em>machine</em> the tagline “it is all screen”. A resolution of 2436 x 1125 is also featured, making it the highest resolution iPhone to date. </p><p>Since the announcement, designers and prototypers have obviously been working in full gear to carve out products and designs to match the upcoming iPhone X. </p><a class="anchor" name="that_notch"></a><h2><a href="#that_notch">That Notch</a></h2><p>This is arguably one of the fascinating features of the iPhone X! (and the wonderful portrait above too). The Notch up top. Bold, elegant, has the flows around it and still fascinating, even though the guy in the portrait below doesn’t seem so thrilled. </p><p><div class="content-img-outer-wrapper" style="max-width:400px;"><div class="content-img-inner-wrapper" style="padding-top: 131.0%;"><img alt="One Notch to Rule All" src="https://cloudinary-res.cloudinary.com/image/upload/w_200,c_fill/dpr_auto/iphone_x_hair_line.jpg" style="margin: 0 auto;display: block" title="One Notch to Rule All" /></div></div></p><p>We have to find a way to make him happy, how to make the notch really beautiful and useful for our images. Let’s do this with Cloudinary image transformation tools.</p><p>The iPhone X screen is unique in that the dark space (notch) that houses the camera and other sensors are actually part of the hard glass screen and content displayed flows around this notch. This is a very important aspect to consider in the UI/UX design of products to fit the <em>all screen</em> iPhone. In this article, we will discuss a way to <em>fix</em> your images, testing how it would look on the iPhone X.</p><p><div class="content-img-outer-wrapper" style="max-width:600px;"><div class="content-img-inner-wrapper" style="padding-top: 83.67%;"><img alt="spot the notch on top" src="https://cloudinary-res.cloudinary.com/image/upload/w_300,c_fill/dpr_auto/iphonexdesign.jpg" style="margin: 0 auto;display: block" title="spot the notch on top" /></div></div></p><a class="anchor" name="how_do_you_work_with_that_screen"></a><h2><a href="#how_do_you_work_with_that_screen">How do you work with that screen?</a></h2><p>Image management and manipulation can be done on-the-fly with Cloudinary. And when I say <em>on-the-fly,</em>  that means that images are manipulated using dynamic delivery of their URLs!</p><p>Cloudinary also offers mobile-first image optimization for mobile design and the best part, it’s easy to use. These images are cached on the CDN and are immediately available upon request.</p><p>Cloudinary’s image management and manipulation service will be used in this article to simulate how images fit on the iPhone X screen. With this, you can test your images and products to see how well they fit on this new type of screenX.</p><p>Before we begin, let’s have a look at the sample image we will be manipulating.</p><p><div class="content-img-outer-wrapper" style="max-width:600px;"><div class="content-img-inner-wrapper" style="padding-top: 133.33%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_300,c_fill/dpr_auto/Spencer_Watson.jpg" style="margin: 0 auto;display: block" /></div></div></p><a class="anchor" name="manipulate_the_image"></a><h2><a href="#manipulate_the_image">Manipulate the image</a></h2><p>To perform this test, you need  the <a href="http://cloudinary-res.cloudinary.com/image/upload/w_300,c_fill,fl_attachment/iphone_x_notch.png" data-popup="true">notch image</a>. 
<div class="content-img-outer-wrapper" style="max-width:300px;"><div class="content-img-inner-wrapper" style="padding-top: 14.67%;"><img alt="iphone_x_notch overlay" src="https://cloudinary-res.cloudinary.com/image/upload/w_300,c_fill/iphone_x_notch.png" style="margin: 0 auto;display: block" title="iphone_x_notch overlay" /></div></div></p><p>Next, upload the image to be manipulated. In our case, we uploaded the overhead swimming pool image displayed above.</p><p>Now we need to apply the manipulation. Images in Cloudinary take the form of:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>https://res.cloudinary.com/<span style="color:#070;font-weight:bold">&lt;cloud_name&gt;</span>/image/upload/<span style="color:#070;font-weight:bold">&lt;transformation_parameters&gt;</span>/<span style="color:#070;font-weight:bold">&lt;public_ID&gt;</span>.<span style="color:#070;font-weight:bold">&lt;image_format_file_extension&gt;</span></pre></div>
</div>
</div></div><p>So to adjust the swimming pool image, we use the URL below, and work on the <code>&lt;transformation parameters&gt;</code> portion: 
    https://cloudinary-res.cloudinary.com/image/upload/ <code>&lt;transformation-parameters&gt;</code> /Spencer_Watson.jpg</p><p>Cloudinary offers lots of image URL manipulation parameters and they can be found <a href="https://cloudinary.com/documentation/image_transformations" data-popup="true">here</a>. For this test, we are going to be using quite a few parameters.  The URL might look a bit scary at first, but scroll down a bit and we will walk you through the whole thing.:</p><p><div class="example multi_code "><a class="anchor" name="transformation"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/c_scale,g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/spencer-watson-36.jpg" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans">if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/c_scale,g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/</span><span class="public_id">spencer-watson-36.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:height</span>=&gt;<span style="color:#00D">562</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">1218</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:overlay</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">325</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:angle</span>=&gt;<span style="color:#00D">90</span>},
  {<span style="color:#A60">:angle</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:flags</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:gravity</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:height</span>=&gt;<span style="color:#00D">1218</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">562</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:gravity</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:overlay</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">325</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:background</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:radius</span>=&gt;<span style="color:#00D">54</span>}
  ])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">transformation</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#369;font-weight:bold">array</span>(
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">90</span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">flags</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">background</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">radius</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">54</span>)
  )))</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>).image(transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">90</span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">flags</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">background</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">radius</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">54</span>}
  ])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">562</span>).width(<span style="color:#00D">1218</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .angle(<span style="color:#00D">90</span>).chain()
  .angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).chain()
  .flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">1218</span>).width(<span style="color:#00D">562</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).chain()
  .background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).radius(<span style="color:#00D">54</span>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">'</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]}).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">90</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">flags</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">background</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">radius</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">54</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">90</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">flags</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">background</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">radius</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">54</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.Transform(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).Chain()
  .Height(<span style="color:#00D">562</span>).Width(<span style="color:#00D">1218</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).Chain()
  .Overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">325</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).Chain()
  .Angle(<span style="color:#00D">90</span>).Chain()
  .Angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).Chain()
  .Flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).Gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).Chain()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).Chain()
  .Height(<span style="color:#00D">1218</span>).Width(<span style="color:#00D">562</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).Chain()
  .Gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).Overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">325</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).Chain()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).Chain()
  .Background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).Radius(<span style="color:#00D">54</span>)).BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">562</span>).width(<span style="color:#00D">1218</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .angle(<span style="color:#00D">90</span>).chain()
  .angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).chain()
  .flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">1218</span>).width(<span style="color:#00D">562</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).chain()
  .background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).radius(<span style="color:#00D">54</span>)).generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson-36.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/c_scale,g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/spencer-watson-36.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:562px;"><div class="content-img-inner-wrapper" style="padding-top: 216.73%;"><img alt="Transformation" src="https://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/c_scale,g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/spencer-watson-36.jpg" style="margin: 0 auto;display: block" title="Transformation" /></div></div></a></p><p>Looking at the URL, you can see what it means:</p>
<ul>
<li><p><code>if_ar_gt_1</code>: If the aspect ratio of the image is greater than 1 (landscape):, 
<code>c_fill,h_562,w_1218</code>: resize the image to a height of 562 and a width of 1218 maintaining aspect ratio
<code>c_scale,l_iphone_x_notch,w_325</code>: add the <code>iphone_x_notch</code> image as an overlay resized  to a width of 325 (regardless of its aspect ratio)
<code>a_90/a_hflip</code>: rotate the <code>iphone_x_notch</code> overlay by 90 degrees and do a horizontal mirror flip on it, 
<code>g_west,fl_layer_apply</code>: ensure the f the notch overlay is located on the far left of the parent image. End transformations to this layer.  </p></li>
<li><p><code>if_else</code>: But if the aspect ratio of the image is not greater than 1 (portrait):
<code>c_fill,h_1218,w_562</code>: resize the image to a height of 1218 and a width of 562, maintaining aspect ratio
<code>c_scale,g_north,l_iphone_x_notch,w_325</code>: add a layer of the iphone<em>x</em>notch image resized  to a width of 325 regardless of its aspect ratio and place it at the center-north of the parent image. </p></li>
<li><p><code>if_end</code>: End the If statement. </p></li>
<li><p><code>b_rgb:000000,r_54</code>: Apply a black background to the image and round the corners to a border radius of 54.</p></li>
</ul>
<p>Let&#39;s take a look at this same transformation on another image, this time a landscape image. All you have to do is use the same conditional transformation URL with a different public ID: </p><p><div class="example multi_code "><a class="anchor" name="test_landscape_image_on_iphone_x"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/v1506615977/country_sunset.jpg" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans">if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/</span><span class="public_id">v1506615977/country_sunset.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:height</span>=&gt;<span style="color:#00D">562</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">1218</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:overlay</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">325</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:angle</span>=&gt;<span style="color:#00D">90</span>},
  {<span style="color:#A60">:angle</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:flags</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:gravity</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:height</span>=&gt;<span style="color:#00D">1218</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">562</span>, <span style="color:#A60">:crop</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:gravity</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:overlay</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">325</span>},
  {<span style="color:#A60">:if</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:background</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:radius</span>=&gt;<span style="color:#00D">54</span>}
  ])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">transformation</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#369;font-weight:bold">array</span>(
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">90</span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">flags</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">325</span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>),
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">background</span><span style="color:#710">&quot;</span></span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">radius</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">54</span>)
  )))</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>).image(transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">325</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">90</span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angle</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">flags</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">height</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">1218</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">562</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">crop</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">gravity</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">overlay</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">325</span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">if</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">background</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">radius</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">54</span>}
  ])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">562</span>).width(<span style="color:#00D">1218</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .angle(<span style="color:#00D">90</span>).chain()
  .angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).chain()
  .flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">1218</span>).width(<span style="color:#00D">562</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).chain()
  .background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).radius(<span style="color:#00D">54</span>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">'</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]}).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">562</span>, <span style="color:#606">width</span>: <span style="color:#00D">1218</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">90</span>},
  {<span style="color:#606">angle</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">flags</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">height</span>: <span style="color:#00D">1218</span>, <span style="color:#606">width</span>: <span style="color:#00D">562</span>, <span style="color:#606">crop</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">gravity</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">overlay</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">325</span>},
  {<span style="color:#080;font-weight:bold">if</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">background</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">radius</span>: <span style="color:#00D">54</span>}
  ]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">90</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">flags</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">background</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">radius</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">54</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">/&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">90</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">flags</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1218</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">562</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">crop</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">gravity</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">325</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">if</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">background</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">radius</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">54</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.Transform(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).Chain()
  .Height(<span style="color:#00D">562</span>).Width(<span style="color:#00D">1218</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).Chain()
  .Overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">325</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).Chain()
  .Angle(<span style="color:#00D">90</span>).Chain()
  .Angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).Chain()
  .Flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).Gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).Chain()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).Chain()
  .Height(<span style="color:#00D">1218</span>).Width(<span style="color:#00D">562</span>).Crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).Chain()
  .Gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).Overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).Width(<span style="color:#00D">325</span>).Chain()
  .If(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).Chain()
  .Background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).Radius(<span style="color:#00D">54</span>)).BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ar_gt_1</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">562</span>).width(<span style="color:#00D">1218</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">scale</span><span style="color:#710">&quot;</span></span>).chain()
  .angle(<span style="color:#00D">90</span>).chain()
  .angle(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">hflip</span><span style="color:#710">&quot;</span></span>).chain()
  .flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">layer_apply</span><span style="color:#710">&quot;</span></span>).gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">west</span><span style="color:#710">&quot;</span></span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">else</span><span style="color:#710">&quot;</span></span>).chain()
  .height(<span style="color:#00D">1218</span>).width(<span style="color:#00D">562</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fill</span><span style="color:#710">&quot;</span></span>).chain()
  .gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">north</span><span style="color:#710">&quot;</span></span>).overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone_x_notch</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">325</span>).chain()
  .if(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">end</span><span style="color:#710">&quot;</span></span>).chain()
  .background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#000000</span><span style="color:#710">&quot;</span></span>).radius(<span style="color:#00D">54</span>)).generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">country_sunset.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/v1506615977/country_sunset.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:1218px;"><div class="content-img-inner-wrapper" style="padding-top: 46.14%;"><img alt="Test landscape image on iPhone X" src="https://res.cloudinary.com/demo/image/upload/if_ar_gt_1/c_fill,h_562,w_1218/c_scale,l_iphone_x_notch,w_325/a_90/a_hflip/fl_layer_apply,g_west/if_else/c_fill,h_1218,w_562/g_north,l_iphone_x_notch,w_325/if_end/b_rgb:000000,r_54/v1506615977/country_sunset.jpg" style="margin: 0 auto;display: block" title="Test landscape image on iPhone X" /></div></div></a></p><a class="anchor" name="bundle_transformations_with_named_transformation"></a><h2><a href="#bundle_transformations_with_named_transformation">Bundle Transformations with Named Transformation</a></h2><p>Let’s do one more cool thing, it feels weird to have to write all those transformation parameters for every image to be transformed. Cloudinary offers the named transformation feature which is used to bundle transformation parameter into one single re-usable parameter. </p><p>In the transformation panel of the Cloudinary dashboard, a list of all transformations currently delivered by Cloudinary on the current user account can be found. Click the edit link at the bottom of each transformation and use “<strong>Save as</strong>” to save the transformation with whichever name you choose. I choose “<strong>iphonex</strong>”.  Once saved, on the list of transformations you can find the named transformation listed as iphonex. This “transformation pack” is now available to all images stored and can be applied to our test image with:</p><p><div class="example multi_code "><a class="anchor" name="api_example_3"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/t_iphonex/spencer-watson.jpg" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans">t_iphonex/</span><span class="public_id">spencer-watson.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">transformation</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>)))</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>).image(transformation=[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>])</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().named(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">'</span></span>, {<span style="color:#606">transformation</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>]}).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>]})</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;Transformation</span> <span style="color:#b48">transformation</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">[</span><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span><span style="color:#F00;background-color:#FAA">]</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#070;font-weight:bold">/&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;cl-transformation</span> <span style="color:#b48">transformation</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">[</span><span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span><span style="color:#F00;background-color:#FAA">]</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#070;font-weight:bold">&gt;</span>
  <span style="color:#070;font-weight:bold">&lt;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.Transform(<span style="color:#080;font-weight:bold">new</span> Transformation().Named(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>)).BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().transformation(<span style="color:#080;font-weight:bold">new</span> Transformation().named(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphonex</span><span style="color:#710">&quot;</span></span>)).generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">spencer-watson.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/t_iphonex/spencer-watson.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:562px;"><div class="content-img-inner-wrapper" style="padding-top: 216.9%;"><img src="https://res.cloudinary.com/demo/image/upload/t_iphonex/spencer-watson.jpg" style="margin: 0 auto;display: block" /></div></div></a></p><p>Read more on named transformations <a href="https://cloudinary.com/documentation/image_transformations#named_transformations" data-popup="true">here</a> and how to implement them <a href="https://support.cloudinary.com/hc/en-us/articles/202521212-How-can-I-create-a-named-transformation-with-multiple-base-transformations-" data-popup="true">here</a>.</p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>Now you have seen how you can manipulate your images to test how they look on the iPhone X screen. You can try this out with several other images and if you are building a product be sure to test it to see how it looks on the iPhone X. This is just one of an unlimited number of cool things you can do with the Cloudinary image manipulation parameters. Check out the <a href="https://cloudydesk.com/iphonex/" data-popup="true">demo here</a></p>]]>
      </description>
      <author />
      <pubDate>Mon, 06 Nov 2017 18:45:38 +0000</pubDate>
      <link>https://cloudinary.com/blog/are_your_website_images_ready_to_embrace_the_iphone_x_notch</link>
      <guid>https://cloudinary.com/blog/are_your_website_images_ready_to_embrace_the_iphone_x_notch</guid>
    </item>
    <item>
      <title>Image Optimization: Expert Roundup</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:1540px;"><div class="content-img-inner-wrapper" style="padding-top: 55.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/Image_Optimization_Roundup_2000x1100.png" style="margin: 0 auto;display: block" /></div></div></p><p>Unoptimized images can be incredible bottlenecks that turn an otherwise well-built web page into a slow loading, bloated one. With the ever-increasing percentage of users on mobile devices, properly sizing and optimizing images to provide a good mobile experience is even more important.</p><p>When working with content creators:</p>
<ul>
<li><p>  Train the content creator on what type of image files to use in different situations. For example, PNG files should not be used for still photos (JPGs are the better choice), but they should be used for web graphics with transparency. PNG-8 can be used for graphics like logos with simple colors, resulting in a smaller file size than PNG-24 (see this <a href="http://designingforperformance.com/optimizing-images/#choosing-an-image-format" data-popup="true">table</a> in Lara Hogan&#39;s &quot;Designing for Performance&quot; book).</p></li>
<li><p>  If using Photoshop, make sure to crop the image where possible, then use the &quot;Save for Web&quot; feature for saving all images that will be used on the site. Within the &quot;Save for Web&quot; options, make sure to specify an appropriate image size and choose the desired image quality (60% is generally a good bet).</p></li>
<li><p>  Provide guidelines for the content creator on maximum file size and dimensions for images that will be uploaded to the site.</p></li>
<li><p>  Run the image through an optimizer like ImageOptim (OSX and Linux, free) or Caesium Image Compressor (Windows, free), or TinyPNG (online).</p></li>
<li><p>  When possible, use SVG instead of PNGs for web graphics because the file size tends to be much smaller and they look crisp on all sizes of screens and devices.</p></li>
<li><p>  Animated GIFs, if used, should be optimized as well (see this <a href="https://design.tutsplus.com/tutorials/10-ways-to-optimize-an-animated-gif-file--psd-34649" data-popup="true">article</a>).</p></li>
</ul>
<p>Tips for developers:</p>
<ul>
<li><p>  Build in an image optimization tool. For a CMS, this can be done with an add-on that optimizes all newly added images, such as the EWWW Image Optimizer for WordPress. For a static site, this can be built into the build tooling for the site, for example: gulp-imageoptim.</p></li>
<li><p>  Programmatically set maximum file size and dimensions for images that can be uploaded to the site if possible. This is built into CMS systems like WordPress and Drupal.</p></li>
<li><p>  Use responsive images. The most straightforward way is to add the image &#39;srcset&#39; and &#39;sizes&#39; attributes to all images. Responsive image functionality is already built into some CMS systems, for example, WordPress uses Picturefill to ensure support of older browsers. Another approach is to use the <code>&lt;picture&gt;</code> element, for cases where you want to do art direction on a photo, with full control over what part of the image is shown at various screen sizes. Third-party tools like Cloudinary are another solution.</p></li>
<li><p>  Audit the site regularly to make sure image best practices are being followed.</p></li>
</ul>
<p>With proper training for content creators and the proper planning and implementation techniques completed up front by developers, images can be an asset and point of differentiation for a website or web app, instead of a frustrating bottleneck.</p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="http://cloudinary-res.cloudinary.com/image/upload/c_thumb,w_100/sheelah-brennan.png" alt=“Sheelah Brennan” title="Sheelah Brennan"></img></td>
<td style = "padding: 10px;"><i><a href="https://twitter.com/sheelah_b" target="_new">Sheelah Brennan</a>, Web developer and owner of, <a href="https://sheelahb.com/">Sheelahb.com</a></i></td>
</tr>
</table>

<hr>
<p>I optimize images as a part of my Magento speed optimization service. E-commerce sites powered by Magento are the complex catalogs with thousands of images. It is impossible to manually optimize every JPEGs or PNGs so I utilize a couple of automatic size reducing techniques.</p><p>I use gifsicle for GIFs, jpegtran for JPEGs and optipng for PNGs - these are command line utilities used as prebuilt packages for your OS. I use the following bash script to find every image and optimize it on the fly:</p><div class="code-holder"><div class="code_inner"><pre>#!/bin/bash

find ./media -iname &#x27;*.gif&#x27; -exec sh -c &#x27;gifsicle -b -O3 -o &quot;{}.out&quot; &quot;{}&quot;; mv &quot;{}.out&quot; &quot;{}&quot;&#x27; \;

find ./media -iname &#x27;*.png&#x27; -exec optipng -o5 -keep -preserve &#x27;{}&#x27; \;

find ./media -type f -iname &#x27;*jpg&#x27; -exec sh -c &#x27;jpegtran -outfile &quot;{}.out&quot; -optimize &quot;{}&quot;; mv &quot;{}.out&quot; &quot;{}&quot;&#x27; \;</pre></div></div><p>This script could be added to cron daemon to optimize the new images as they come in (see this <a href="https://linuxacademy.com/blog/linux/the-cron-daemon/" data-popup="true">post</a> for more details).</p><p>The second technique I use is called the Google PageSpeed Module, a server extension which you can install either for Nginx or Apache. This tool optimizes images and caches them on the server. The configuration is simple:</p><div class="code-holder"><div class="code_inner"><pre>ModPagespeedRewriteLevel CoreFilters</pre></div></div><p>The CoreFiters filter includes image optimization as well as many other useful speed optimization tools (see <a href="https://modpagespeed.com/doc/configuration">https://modpagespeed.com/doc/configuration</a>).</p><p>The third method I sometimes use to polish images that are already optimized by the first two techniques is to run the page through Google PageSpeed Insights, and then download the optimized image pack (you can find the download link at the bottom of your pagespeed report, see <a href="https://developers.google.com/speed/docs/insights/OptimizeImages">https://developers.google.com/speed/docs/insights/OptimizeImages</a>). But even with the PageSpeed module installed, Google Insights can still squeeze a few kilobytes here and there. The third method requires a lot of manual work and patience, but it will pay off.</p><p><em>Contributed by Konstantin Gerasimov, CEO, <a href="https://www.goivvy.com/hire-magento-developer" data-popup="true">Goivvy</a></em></p>
<hr>
<p>Amongst the many file formats out there, we&#39;re going to these three popular formats. It&#39;s might not be critical for a common user to know the exact difference between them, but it is more crucial when it comes to image optimization.</p><p>Here is our take on so-called optimized and progressive types of image files.</p><p>Optimized JPEG or optimized PNG (also called non-interlaced PNG) creates improved image files with smaller sizes. The browsers loads such files top-to-bottom while, and the image data arrives gradually. This provides the best compression for image files under 10K, which is usually preferable.</p><p>Progressive JPEG or progressive PNG (also called interlaced PNG) allows to display the low quality images before all the graphic info is loaded. The more information is loaded, the better the image quality. This format usually provides better compression for files over 10K.</p><p>After we have come to an understanding of which image format is better for different types of images on your e-commerce site, we&#39;d like to touch on the way to compress all images on the site to reduce their size.</p><p>However, even if you choose the most appropriate format for your images, they still might be huge in size. The better quality an image has, the more it weighs. When you have thousands of pictures in your online store, even 10% image compression will substantially improve the page load speed.</p><p>Quoted from: <a href="http://promokit.eu/prestahop-blog/image-optimization-to-speed-up-your-site/">http://promokit.eu/prestahop-blog/image-optimization-to-speed-up-your-site/</a> (edited)</p><p><em>Contributed by Kate Green, <a href="http://promokit.eu" data-popup="true">Promokit</a></em></p>
<hr>
<p>Images are very important for web articles. For a great article, you need well optimized articles with proper keywords and attractive images. However, for a better user experience, images should be optimized. For example, if a visitor views your article and it&#39;s taking time to load the image, they might leave your site. Furthermore, search engines might rank you lower in search results.</p><p>You need to optimize your images. The thumb rule I follow is to use images that are less than 50kb in size, while maintaining the quality. Sometimes, I may go up to 60-70kb, but no more than that.</p><p>The tools which I like to use for image optimization are free and provide good results. After finding an image and editing it, I always compress it using compressor.io and then compress further using tinypng.com. I also use the Advanced Lazy Load WordPress plugin, which reduces the page load time and provides a great user experience.</p><p>For more details, see: <a href="http://www.tech2blog.com/websites-find-creative-commons-zero-images/" data-popup="true">Websites to Find Creative Commons Zero Images</a>.</p><p><em>Contributed by Pawan Bahuguna, Owner, <a href="http://www.tech2blog.com/" data-popup="true">Tech2Blog</a></em></p>
<hr>
<p>Image optimization may appear to be a bit complex, but with a few tricks, you&#39;ll master it in no time. When it comes to anything on the Internet, content may be king, but a picture is worth a thousand words. This is the reason why it is key that you optimize any images that you use on your website.</p>
<ul>
<li><p>  Image Quality: It&#39;s only logical that any image you choose to place on a website will be of the highest quality imaginable. But you&#39;d be surprised at the amount of poor quality images you&#39;ll run across, on some of the most popular websites out there. The best way to approach this is to take an in-depth look at the image and check for clarity. After that you can check resolution vs. size to make sure the image quality is consistent for resizing.</p></li>
<li><p>  Image Size: There are plenty of new plugins and tools that help automate image resizing. Where these tools are not employed, you can use Photoshop, Pixlr editor, or even basic paint to resize images. Be sure to always check constrain proportions so that your image quality stays intact.</p></li>
<li><p>  Image Alignment: This is one of the most commonly overlooked of all image optimization elements. There are usually 3 main options to align images online: left, center, and right. You can align images this way and have them text-wrapped (left and right alignment is ideal for text wrapping). Center is typically used only to feature an image and have the text positioned above or below the image.</p></li>
<li><p>  Image Title, Meta, and SEO: Recently, it has become mandatory for all images to be appropriately optimized for search engine ranking purposes. First, the title of your image should coincide with the page name, keyword, or post name that you are targeting. Additionally, you can caption the image with keywords or explain the picture in detail to the audience. It is a good idea to also incorporate subject and keyword phrases or terms in the alternate text option.</p></li>
</ul>
<p>Search engines pick up images and rank them in their listings for those specific terms. This assists you in not only enhancing your content ranking in the serps, but it also boosts your ranking and traffic through those looking for particular images via keywords.</p><p><em>Contributed by Matt Hall, Owner, <a href="http://sceptermarketing.com" data-popup="true">Scepter</a></em></p>
<hr>
<p>One of the main reasons for increased page load times is images on the page!</p><p>How to do it right:</p>
<ul>
<li><p>  Progressive Image Loading: Your web page is not available for use until all the images (<code>&lt;img&gt;</code> tags) are loaded with an image from their src. So, first replace all your img tags with placeholders. The placeholders will be a blank area on your web page which will be replaced by the high-resolution images. Doing so will allow your web page to continue execution without hindering the loading of page. For any image that you need to show you must have two versions of it, one is of high resolution and other is of low resolution (max 1kb in size).</p></li>
<li><p>  Host Images on a CDN: When the images are hosted on a CDN, it takes the load off our application. Also, when we make multiple requests, we get a cached copy, which is much faster.</p></li>
<li><p>  Choose a Proper File Format: If the images are composed of simple geometric shapes, they are great candidates for the vector (SVG) format. Images with complex shapes, colors, and details ought to be saved in one of the raster formats (GIF, PNG or JPEG).</p></li>
<li><p>  Use CSS Sprites: If there are many icon images on the page, combine them into one image and display them with plain CSS. This will eliminate the multiple requests for different icons as we are loading one single combined image.</p></li>
</ul>
<p>How is it done wrong?</p><p>Most of the time, we need to use high resolution images to provide a good user experience. This results in slow page load on slow networks, which not only reduces user&#39;s interest but also affects the pagerank/crawling done by the search engines. We can reduce the quality of the images, but that doesn&#39;t solve it.</p><p>Here are some tips and tricks:</p>
<ul>
<li><p>  Most developers use a basic low-resolution placeholder, such as a loading icon, until the image gets loaded. This makes the UI dull and the user feels the site is slow.</p></li>
<li><p>  Also, don&#39;t use only one master low-resolution image. Showing the same low-resolution image in 10 places until the page gets loaded makes for a bad user experience.</p></li>
<li><p>  Create two separate versions (low and high resolution) of images and use a unique low-resolution version for each image.</p></li>
<li><p>  Start the loading of the images after the page is fully loaded. This is relevant for blogging sites where user care more about content rather than the media attached to it.</p></li>
<li><p>  Create multiple high-resolution versions of the image, such as one each for desktop, mobile, tablets, and render high-resolution images based on device.</p></li>
<li><p>  Prefer vector formats: vector images are resolution and scale-independent, which makes them a perfect fit for the multi-device and high-resolution world.</p></li>
</ul>
<p><em>Contributed by Ankur and his team at <a href="http://www.botreetechnologies.com" data-popup="true">BoTree Technologies</a></em></p>
<hr>
<p>Image optimization means making your images effective enough to be understood easily by search engines as well as users. Here, I&#39;m not only talking about creating an attractive image that catches immediate user attention. Image optimization is more than that.</p><p>Let&#39;s say that you make an image compelling enough to catch a user&#39;s eye and understandable enough to deliver your message. But what about search engines? They are not humans like you and me. They are bots that won&#39;t see your image or its colors.</p><p>For example, I want to create an image of the sea under a blue sky during daytime. To make it readable for search engines, I&#39;ll use an Alt Tag with the name &quot;Sea Under Blue Sky During Day Time&quot;:</p><div class="code-holder"><div class="code_inner"><pre>&lt;img src=&quot;/seaunderbluesky.jpg&quot; alt=&quot;Sea Under Blue Sky during Day Time&quot; /&gt;</pre></div></div><p>Next, I&#39;ll give it a proper description to make it more recognizable:</p><div class="code-holder"><div class="code_inner"><pre>&lt;meta name=&quot;description&quot; content=&quot;This photo is about blue sky, surface, horizon.&quot;/&gt;</pre></div></div><p>Plus, I&#39;ll take care of its uniqueness by adding the &quot;.jpg&quot; extension: seaunderbrightbluesky.jpg.</p><p>This is just a brief of how you can optimize your images to make them easily understandable by both search engines as well as users.</p><p><em>Contributed by Jimit Bagadiya, <a href="http://socialpilot.co" data-popup="true">SocialPilot</a></em></p>
<hr>
<p>When printing images in a book, there are a few specific requirements to consider for optimal results. First, while a minimum resolution of 150 ppi will most likely be satisfactory, 300 ppi is optimal. Images should also be saved in JPEG format with maximum quality settings. If you&#39;re able to apply a color-space, we recommend sRGB, as it most closely resembles the eventual print device.</p><p>Also, keep in mind that printed images usually print darker than they appear on a computer screen. For this reason, we recommend that you lighten each image and apply sharpening as a last step, prior to placing it into a book design. Following the information above will likely give you great print results, but if you need more information or are interested in soft-proofing your images, a good print provider will also have a color-management page on their website. Check out Blurb&#39;s <a href="http://www.blurb.com/guides/color_management/workflow" data-popup="true">color management resource center</a> for more information.</p><p><em>Contributed by Estee Shechter, <a href="http://www.blurb.com/" data-popup="true">Blurb</a></em></p>
<hr>
<p>An image is worth a thousand words, but it&#39;s also worth a boost in conversions. There is nothing worse than stretched, improperly sized, or inconsistent images. It&#39;s a dead giveaway to visitors that your site isn&#39;t professional and therefore not trustworthy.</p><p>When you visit a quality e-commerce site, their images and thumbnails always seem to line up in a nice grid, right? The trick is to maintain a consistent aspect ratio. That&#39;s the ratio of the width to the height of an image or screen. Maybe you&#39;re not up on your geometry, so I&#39;ll make it simple for you: you just need to make all of your product images square.</p><p>Maintaining the correct aspect ratio in Photoshop is surprisingly easy, just hold down the shift key down while cropping or making a selection to maintain an aspect ratio. The crop tool can also be set to to a square. Remember to keep your photo centered.</p><p>When saving images for the web, we need to strike a balance between file size and quality. For most images, the above settings when used in Adobe Photoshop CS5 will yield excellent quality within minimal file sizes. If you select &quot;optimized&quot; you may get a slightly smaller file size. Resist the temptation. We know that progressive JPEGs (while bigger) will appear to load faster to the user.</p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="http://cloudinary-res.cloudinary.com/image/upload/c_thumb,w_100/headshot_KurtElster03.jpg" alt=“Kurt Elster” title="Kurt Elster"></img></td>
<td style = "padding: 10px;"><i><a href="https://twitter.com/kurtinc" target="_new">Kurt Elster</a>, MBA and owner of, <a href="https://ethercycle.com/">Ethercycle</a></i></td>
</tr>
</table>

<hr>
<p>Our company deals a lot with video files. Our video converter tool is capable of converting any resolution videos and preparing them for website integration. Some corporate website owners prefer to host videos on their own servers instead of uploading them to YouTube or other video platform. So they must have a fast CDN to provide sufficient video buffering speed and cross-platform accessibility. I think a good cloud-based system like Cloudinary can help optimize your &#39;cost-quality&#39; ratio.</p><p>As for technologies, I&#39;m after HTML5. It&#39;s a new standard of web markup which has been already adopted by major content providers. Our stats show that since 2016, the conversion to HTML5 outperforms the conversion to Flash formats, which means that users also opt for this new progressive technology.</p><p><em>Contributed by Emily Cooper, Marketing VP, <a href="http://www.freemake.com/" data-popup="true">Freemake</a></em></p>
<hr>
<p>When developing web stores, image enhancement is key. According to <a href="http://httparchive.org/interesting.php" data-popup="true">HTTP Archive</a>, the average page size today is 2.9MB, while images are taking up over half of this size. Image enhancement is a must-have to adhere for reducing page size as well as page load time. This also influences Google rankings while increasing customer loyalty.</p><p>One of the key approaches for enhancement is proper use of formats. For example, when saving images in JPG format, you increase its original size. Moreover, you complicate things for the user, because JPG implies image artifacts that are noticeable in the text. Therefore, the format should be chosen according to content:</p>
<ul>
<li><p>  SVG is considered to be ideal for vector graphic, diagrams and graphs.</p></li>
<li><p>  PNG is useful for various clipart and images with open areas.</p></li>
<li><p>  JPG is a perfect solution for photos.</p></li>
<li><p>  GIF is suitable for animated images.</p></li>
</ul>
<p>Nowadays there are so many ways to perform image enhancement including online tools, extensions for your website, and applications. In most programs and tools, proprietary algorithms as well as add-in programs are used, for example, pngcrush, optipng, jpegtran, jpegoptim, or gifsicle. Besides, you should remember that operations are executed without deteriorating image quality.</p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="http://cloudinary-res.cloudinary.com/image/upload/c_thumb,w_100/Guryanov.jpg" alt=“Denis  Guryanov” title="Denis  Guryanov"></img></td>
<td style = "padding: 10px;"><i><a href="https://twitter.com/denisguriyanov" target="_new">Denis  Guryanov</a>, Frontend Developer at, <a href="https://belvg.com/">BelVG</a></i></td>
</tr>
</table>

<hr>
<p>Image optimization is a deceptively complicated area. Where is the sweet spot between a fast site but one that runs with images of a high enough quality to capture visitors&#39; imagination? Here are a few of my favorite techniques that can reduce your image size without negatively impacting your visitor experience:</p>
<ul>
<li><p>  Resize them: I&#39;ve seen so many sites loading massive images just to resize them on the page.  Bloated 3000+ pixel image codes to appear as 250px wide, eating up bandwidth and slowing down the site. Figure out what the size of the image will display as on the page, and resize your images accordingly. This is by far the simplest and highest value of all image optimization to-dos.</p></li>
<li><p>  Optimize Them: We&#39;re talking about optimizing the actual images to appear the same but be smaller in size. You can either use a tool such as TinyPNG, which strips out some of the image metadata and uses lossy compression to reduce the number of colors in the image. Nine times out of ten the resulting product looks exactly the same on a monitor or close enough. However, I tend to shy away from these tools as the one time in ten (more for some tools) is unacceptable and not worth the trade-off.</p></li>
<li><p>  Use a Content Delivery Network (CDN): Your web server works hard for you every day processing all your pages, sending out emails (some anyway), hosting your cPanel and a ton more. Add serving all your images to the mix, and you&#39;ll be slowing down the entire system. A CDN hosts the images on servers dedicated to the single task of presenting them to the world. Most CDN providers also have multiple datacenters and serve the images from the one that is closest to your visitor.</p></li>
<li><p>  SCRSET: A typical page would call an image with code similar to the following:</p></li>
</ul>
<div class="code-holder"><div class="code_inner"><pre>&lt;img src=&quot;desktop-image.jpg&quot; alt=&quot;Hopefully you have one.&quot;&gt;</pre></div></div><p>The problem with this is that the same image is being served for mobile devices and desktop. Basically, mobile devices are pulling in images that are generally larger than they need to be, thus slowing down the page load for the already slower device. A simple switch in the code to something like the following might help:</p><div class="code-holder"><div class="code_inner"><pre>&lt;img src=&quot;mobile-image.jpg&quot; srcset=&quot;tablet-image.jpg 500w, desktop-image.jpg 1200w&quot; alt=&quot;If you&#x27;re using SRCSET this is probably done.&quot;&gt;</pre></div></div><p>In this case, the browser will make the calculations as to which image to use based on the resolution the device needs. Even if you had only two images, one for mobile and one for desktop, you&#39;ll be doing a great favor to your visitors.</p><p><em>Contributed by Dave Davies, CEO, <a href="https://www.beanstalkim.com/" data-popup="true">Beanstalk Internet Marketing</a></em></p>
<hr>
<p>To make GIF files smaller in size, there are two optimization methods:</p>
<ul>
<li><p>  Lossy compression: This removes some of the data from the original file. The result is a reduced file size, and reduced quality. The result image can become fuzzy and pixelated over time.</p></li>
<li><p>  Lossless compression: This reserves all of the data from the original file. While the file size remains larger than than lossy compression, the image&#39;s quality does not degrade over time.</p></li>
</ul>
<p>If those two methods aren&#39;t sufficient, GIF images can be converted to other file formats.</p><p>The easiest alternative for static GIF images is to convert them to PNGs. While the two formats are very similar in terms of choices for displaying simple graphics, PNG has the advantage for being able to compress to up to 25 percent smaller than an equivalent GIF file.</p><p>PNGs can be a great alternative for static GIFs while HTML5/MP4 that are considered more modern techniques, are more suited for alternatives to animated GIFs. Simple graphics such as lines or shapes can also be made using SVG or pure CSS. These are more robust and smaller in size.</p><p>Quoted from: <a href="https://www.eyerys.com/articles/how-optimize-gif-format-performance-and-knowing-alternatives">https://www.eyerys.com/articles/how-optimize-gif-format-performance-and-knowing-alternatives</a></p><p><em>Contributed by Hafiz Rahman S., <a href="https://www.eyerys.com" data-popup="true">Eyerys</a></em></p>
<hr>
<p>Image optimization is a crucial part of enhancing your web page&#39;s overall performance, but unfortunately, it is neglected by most web page owners. However difficult it may seem to a non-technical person, image optimization is quite easy to perform. Here are a few easy hacks to optimize the performance and quality of images on your website.</p>
<ul>
<li><p>  Image size and quality are two important factors in image optimization. Arriving at a point where you get the best image quality at the lowest possible file size is the key to image optimization. Images obtained from the web, or any other source, are often large in size and need to be compressed before uploading, to ensure the faster performance of your web page. It is important to choose the right file format and image compression tool to achieve this goal. The JPEG file format is the best for image compression as it uses both lossy and lossless optimization. GIFs are good for animated images. Everyday tools such as Adobe Photoshop or other freely available image editing tools can be used to compress the images.</p></li>
<li><p>  Naming the image properly is a quick trick to optimize the performance of your image. Did you know that inserting a few keywords (separated by hyphens) into the image&#39;s file name can increase its visibility manifolds? However, refrain from adding too many keywords---three to five keywords in the image file name are adequate. Many people make the mistake of using abbreviations in the image name. Avoid this at all costs.</p></li>
<li><p>  Make the alt text descriptive. It is a good idea to describe your image in the best possible manner (use 10 to 15 words), because Google considers alt text as a ranking factor. Also, alt text is identified by readers.</p></li>
<li><p>  Image Captions cannot be ignored. Studies show that most people read the image captions first, and then decide whether they should read the rest of the content or not.</p></li>
</ul>
<p><em>Contributed by Venkatesh C.R., CEO and Managing Director at <a href="http://www.dotcominfoway.com/" data-popup="true">Dot Com Infoway</a></em></p>
<hr>
<p>One of Webflow&#39;s core values involves immersing the artist in the medium is an essential part of the design. With regard to responsive images, this means previewing the effects of srcset/sizes and intrinsic size in the designer, as you move nodes around and change styles. Intrinsic size can affect a layout in unexpected ways, so getting that feedback as soon as possible is important to the design process.</p><p>When it comes to finding the right balance to optimizing responsive variants, we apply lossless compression optimizations. We do breach into lossy optimizations but try to be careful about it by using perceptual image coders with high-quality settings. The variety of images we encounter is one reason, but ultimately we&#39;d lean toward quality over reducing file size. We also rely on HTML5 standards to optimize page speed via prefetching.</p><p>By being wise about the gap between your breakpoints and responsive variant widths, you can also get a lot out of a simple browser cache for repeat visitors with differing window widths. I resize my browser window all the time, and wouldn&#39;t want variants so specific that I keep downloading slightly larger versions of the same image.</p><p>Quoted from: <a href="https://blog.ycombinator.com/how-to-use-responsive-images/">https://blog.ycombinator.com/how-to-use-responsive-images/</a></p><p><em>Contributed by Yoav Givati, Engineer, <a href="https://webflow.com/" data-popup="true">Webflow</a></em></p>
<hr>
<p>Image Optimization Tips</p><p>Image optimization is a tricky business, and it can make the difference between a decent looking site and a truly beautiful one. Here are a few best practices for optimizing images for websites. These tips regard using Photoshop, ImageAlpha, and ImageOptim.</p>
<ul>
<li><p>  Photoshop allows you to &quot;Save for Web&quot; with the quality setting as low as possible (35-55%). This setting compresses your image, removing some of the image quality in the process. When saving for web, it&#39;s best to look at the preview window while adjusting the quality until you find a good balance between the image file size and quality. To smooth out and counteract the pixelation, you can add a bit of blur (0-.1), depending on the actual composition and detail of the photo.</p></li>
<li><p>  Images with text require higher quality, because the text will appear pixilated before the rest of the image. I use 55% as my recommended starting point, and then you can try decreasing the quality until you have gone too far with the compression--then bump it back.</p></li>
<li><p>  Images that have lots of solid colors (simple background gradients and graphics) can usually get away with a lower quality, as related to compression, because there is not a lot going on in the image. 35% is a good place to start.</p></li>
<li><p>  Photographs of people and landscapes are somewhere in the middle, the key is to get the file size as small as possible without compromising image quality.</p></li>
<li><p>  ImageAlpha is a free app that removes extra colors from your image. You simply drag your file into the app and reduce the number of colors (256, 128, 64, etc), which also reduces the file size. You can play with the settings and A/B test the image with various settings.</p></li>
<li><p>  ImageOptim removes excess metadata from your file, sometimes reducing file size by as much as 15-20% without losing any image quality. I highly recommend this step as it is fast, easy, free, and does not compromise the image.</p></li>
<li><p>  For full-screen images, you should shoot for less than 500k in file size. Ideally, a web page shouldn&#39;t be larger than 1-2MB to load quickly on mobile.</p></li>
</ul>
<p>Dealing with Responsive Images</p><p>It&#39;s important that images are actually larger than the area they display in, because retina screens (such as in MacBooks, iMacs, iPads, and iPhones) contain twice the pixel information per inch. I develop for 2560px screens (27&quot; iMac for example), so any image that should take up the entire screen should be at least 2560x1440 (16:9 ratio). Double that size if you want it to be retina-ready.</p><p>Any image that is inside of a column in the content area should be a standard ratio (3:2, 4:3, 1:1) and its size depends on the site width, for example, 1080px.</p>
<ul>
<li><p>  If you want an image to go &quot;site width&quot; it should be at least 1080px wide.</p></li>
<li><p>  If you want the images to look stellar on retina screens you must double those sizes.</p></li>
<li><p>  1/1 column is 1080px (2160px retina)</p></li>
<li><p>  1/2 column is 540px (1080px retina)</p></li>
<li><p>  1/3 column is 360px (720px retina)</p></li>
<li><p>  1/4 column is 270px (540px retina)</p></li>
<li><p>  1/5 column is 216px (432px retina)</p></li>
<li><p>  1/6 column is 180px (360px retina)</p></li>
<li><p>  A standard WordPress thumbnail is 150px (300px retina)</p></li>
</ul>
<p>All of this is changeable and is dependent on the &quot;site width&quot; setting of your website.</p><p>Responsive Breakpoints</p><p>The size at which a website switches from a multiple column layout to a one-column layout is referred to as the column breakpoint. A standard column breakpoint is usually around 800px. Any image that you want to be the full width of the column breakpoint should be at least 800px wide.</p><p><em>Contributed by John F. Van Dinther, <a href="http://www.twohatsconsulting.com" data-popup="true">TwoHatsConsulting</a></em></p>
<hr>
<p>When it comes to images, keep in mind that images dimensions are not the only thing that matters, but also the compression level. Two images with the same dimensions can have a very different weight, depending on how you compress them. I&#39;ll outline three compression methods:</p>
<ul>
<li><p>  Manual compression: If you aren&#39;t comfortable enough with Photoshop, ImageOptim can be used to compress a bunch of images on the fly. It will reduce the file size with lossless algorithms, so you won&#39;t lose in quality, and will also remove redundant image metadata. They also support the new Guetzli JPEG encoder, released in March 2017 by Google. If you want to integrate it with your website, there&#39;s also a <a href="https://imageoptim.com/api" data-popup="true">web service</a> available (but it isn&#39;t free). For Windows users, you can check out FileOptimizer.</p></li>
<li><p>  Client-side compression:</p></li>
<li><p>  ImageOptim, already mentioned for manual compression, can be used for client-side compression in the form of a <a href="https://github.com/JamieMason/grunt-imageoptim" data-popup="true">Grunt</a> plugin. After a quick setup, the plugin compresses all images located inside the images folders defined in your gruntfile. This solution is very efficient, but has one downside: if your platform frequently publishes content with images, you&#39;ll have to run Grunt at short intervals.</p></li>
<li><p>  You can also leverage the Javascript Image Compression (<a href="https://github.com/brunobar79/J-I-C" data-popup="true">JIC</a>) library. By attaching this library to your images upload fields or WYSIWYG text area, your browser automatically compresses your 4MB image into a much smaller, web-friendly image. Combined with an image resizing library, we are getting closer to a fully automated image processing.</p></li>
<li><p>  You can also combine both, by using Grunt for your general images, that are part of the look and feel, and JIC for user-uploaded content.</p></li>
<li><p>  Server-side compression: The <a href="https://github.com/pagespeed/mod_pagespeed" data-popup="true">mod_pagespeed</a> Apache module (also available for nginx and IIS) performs a bunch of server-side operations that serve your site&#39;s performance, such as minifying, compressing, concatenation of JavaScript and CSS files, better resource caching, deferred loading of assets, and of course image optimization and compression. Together with helping your PageSpeed Insights, you&#39;ll gain in page load time and automation. It won&#39;t replace all the optimization that you can do upfront, but it&#39;s a easy way to improve performance and reduce page size.</p></li>
</ul>
<p><em>Contributed by Morgan Milet, <a href="https://dropsolid.com" data-popup="true">Dropsolid</a></em></p>
<hr>
<p>There are two main reasons that image optimization tools are so popular. The first is related to usability improvement: You&#39;ll experience improved page load time after images on your page are optimized. The second is the fact that optimized images equal saving disk space.</p><p>Image optimization serves usability because the smaller the image, the faster the page load time for the user. Load speed is a factor that has a great impact both on usability and website optimization. In addition, you can save disk space if you upload optimized images to your website.</p><p>Supsystic&#39;s free version of the Photo Gallery plugin solves these issues by allowing you to optimize thumbnails, save backups of source files, compare the appearance of compressed and optimized files, and more. See our <a href="https://supsystic.com/documentation/image-optimize/" data-popup="true">documentation</a> for more details.</p><p><em>Contributed by <a href="https://supsystic.com/" data-popup="true">Supsystic</a></em></p>
<hr>
<p>An active site includes a maximum of 5-7 images in each of its blog posts. Optimizing 5-7 images a day is not a big issue. Here are some image optimization tips and tricks:</p>
<ul>
<li><p>  Select only PNG/JPEG image formats for better optimization.</p></li>
<li><p>  Always add an image title, a description and alt text while uploading an image in WordPress.</p></li>
<li><p>  Use high-end hosting for better image load speed.</p></li>
<li><p>  Mention image credits if required, to avoid copyright issues.</p></li>
</ul>
<p>Here are few recommended image optimization tools and technologies:</p>
<ul>
<li><p>  Compress your images using selected WordPress plugins (see our <a href="https://www.loudtechie.com/speed-up-your-wordpress-blog-with-10-best-image-optimization-plugins/" data-popup="true">post</a> on the subject).</p></li>
<li><p>  I recommend the following free tools for image compression: TinyPNG, Compressor.io, Kraken Image Optimizer.</p></li>
<li><p>  You can also use CDNs such as Cloudinary, MaxCDN, Amazon&#39;s AWS, and more.</p></li>
</ul>
<p>To avoid mistakes:</p>
<ul>
<li><p>  Never upload an uncompressed image.</p></li>
<li><p>  Do not over-compress your image with multiple tools that might damage image quality.</p></li>
</ul>
<p><em>Contributed by Alok Rana, <a href="https://www.loudtechie.com/" data-popup="true">LoudTechie</a></em></p>
<hr>
<p>In these times of large screen resolutions and massive full-screen images, image optimization is more important than ever. As a WordPress theme development company, we often stumble upon websites where images are being heavily scaled instead of displaying images with the optimal size and image dimensions. When selecting a WordPress theme, it&#39;s highly recommended to choose one that&#39;s displaying thumbnails that are sized correctly, without wasting valuable page load time on image scaling.</p><p>Another important aspect is to optimize images before you even upload the images to your website. It usually is disadvantageous to upload a portrait image, if your website is optimized for landscape images. For example if you&#39;re running an online magazine or news website, it would be recommended to optimize the size and image ratio before uploading the image to your site. This not only saves server space, but also helps avoid other image-related issues.</p><p>In addition, always make sure that the images on your website are compressed. Serving optimized and compressed images with less file size can speed up your website, save bandwidth. You usually won&#39;t lose image quality, at least not in a way that it&#39;s noticeable by the human eye.</p><p><em>Contributed by Michael Hebenstreit, <a href="https://www.mhthemes.com/" data-popup="true">MH Themes</a></em></p>
<hr>
<p>The best tip I can provide is: Automate your image optimizations. If your optimizations can be offloaded to a service or build/deploy process, your server or your framework/CMS can use that. Use tools. Don&#39;t get stuck following rules that may not suit your current project.</p><p>If you&#39;re not using a service, there are three tools you can put in your toolbox:</p>
<ul>
<li><p>  MozJPEG for all your basic JPEG optimization needs. Typically MozJPEG&#39;s default settings provide big wins in file size. The easiest way to install this across many operating systems is through NPM.  </p></li>
<li><p>  For PNG images, use PNGQuant and/or ZopfliPNG. If you don&#39;t want to lose any pixels (lossless compression), use only ZopfliPNG.</p></li>
<li><p>  For Animated GIFs... well, don&#39;t use them. Use either a WebM or MP4 file converted with FFmpeg or an animated WebP image with mixed compression mode using Google&#39;s gif2webp. Additionally, you can use animated PNGs for compression on Safari and Firefox-based browsers.</p></li>
<li><p>  Send or serve the appropriate image for each browser.</p></li>
<li><p>  Animated images might be a pain point if you want good cross-browser support. Most Blink-based browsers support animated Webp images.</p></li>
<li><p>  Firefox, Safari, and  Chrome (as of version <a href="https://www.chromestatus.com/feature/6691520493125632" data-popup="true">59</a>) can use Animated PNGs. However, if you&#39;re sending anything other than an animated WebP to Chrome, you&#39;re sending more data than you actually need to. The Picture Element or Content Negotiation for WebP images is your best bet (see our <a href="https://corydowdy.com/blog/webp-jxr-nginx-content-negotiation-test" data-popup="true">post</a>).</p></li>
</ul>
<p>To wrap all these tools into a nice package, MacOS users can use Imageoptim. Windows users can use the above Node/NPM tools, or install them through Bash on Ubuntu or Windows.</p><p><em>Contributed by <a href="http://corydowdy.com" data-popup="true">Cory Dowdy</a></em></p>
<hr>
<p>Image optimization is one of those things that will always be a huge performance killer when it comes to websites. Unfortunately, this is something that users will always ignore or put off to the last minute. As someone who works in the web performance industry, I see bad practices on a daily basis. For example, users uploading full resolution-images that are 5+ MB, not utilizing a CDN to speed up distribution, or not sizing images down beforehand, which in turn leaves CSS to rescale them.</p><p>Here are a few quick tips I give people whenever I see unoptimized images slowing down their site:</p>
<ul>
<li><p>  Images need to be compressed. Whether you go lossy or lossless, it&#39;s important to pick one and roll with it. I personally recommend lossy for most users, as they will see the greatest speed increases. A lot of times images can be compressed by up to 60%+.</p></li>
<li><p>  Compressing images doesn&#39;t have to be complicated. If you&#39;re using a tool like Photoshop or Affinity Photo, simply utilize the &quot;save for web&quot; feature and quality indicator bars when you save out a file. If you are using a CMS like <a href="https://wordpress.org/" data-popup="true">WordPress</a>, there are dozens of WordPress image optimization plugins that can automate the compression upon uploading to the media library.</p></li>
<li><p>  Look into other file types which can further reduce the size of your images. I highly recommend utilizing both SVGs and WebP if you can. SVGs work great for logos and icons. <a href="https://developers.google.com/speed/webp/" data-popup="true">WebP images</a>, Google&#39;s image format, have been shown to be drastically smaller than both JPG and PNG.</p></li>
<li><p>  Resize your images in a photo editing tool before uploading to your site, or utilize a plugin. If your web page is 800px wide and you upload a photo that is 1400px wide, CSS is going to have to scale it down to fit the page. This adds to your load time. I suggest also doing some research into <a href="https://www.smashingmagazine.com/2014/05/responsive-images-done-right-guide-picture-srcset/" data-popup="true">responsive images</a> (retina) as you will want to also take this into account when making your image size calculations.</p></li>
<li><p>  CDNs are here for a reason, and they can drastically increase the load time of your optimized images by distributing them from servers closer to your users (which reduces latency). They can also help the performance of your entire site by ensuring that not only your images, but also your other assets, as they are delivered via a fast HTTP/2 connection with multiplexing, server push, etc.</p></li>
</ul>
<p>There are numerous other things that can be done, such as lazy loading your images or using web fonts like Font Awesome in place of images on your site. In 2017, there should there are no more excuses for sites running slow due to large, unoptimized images. There is plenty of free information out there on how to get started.</p><p><em>Contributed by Brian Jackson, Director of Inbound Marketing, <a href="https://kinsta.com/" data-popup="true">Kinsta</a></em></p>
<hr>
<p>I like solving tricky programming problems ( think of them as Sudoku puzzles or clever logic problems). So I probably enjoy complex algorithms more than most developers. However, even I find some image compression algorithms daunting. I could probably cobble together a simple one if I had to, but fortunately, I don&#39;t. I work mostly in C# and Visual Basic these days, and the .NET framework that they use provides a reasonably nice image compression tool.</p><p>The System.Drawing.Image class provides a Save method that saves an image into a file. Optional parameters let you specify the file type (.bmp, .jpg, .png, and so forth) and a compression level. To specify the file type, loop through the array of encoders returned by the ImageCodecInfo.GetImageEncoders method until you find one with the right Multipurpose Internet Mail Extensions (MIME) type.</p><p>The following code shows a simple GetEncoderInfo method that returns an encoder for a MIME type.</p><div class="code-holder"><div class="code_inner"><pre>// Return an ImageCodecInfo object for this mime type.

private ImageCodecInfo GetEncoderInfo(string mimeType)

{

   ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();

   for (int i = 0; i &lt;= encoders.Length; i++)

   {

       if (encoders[i].MimeType == mimeType) return encoders[i];

   }

   return null;

}</pre></div></div><p>To set the compression level, create an EncoderParameters object. Give it a parameter of type System.Drawing.Imaging.Encoder.Quality with a value between 0 and 100. The value 0 provides high compression and low image quality. The value 100 provides high image quality and a large file (probably larger than the original file).</p><p>The following SaveJpg method uses the GetEncoderInfo method to save an image into a file with a specified compression level (I&#39;ve skipped error handling to save space):</p><div class="code-holder"><div class="code_inner"><pre>// Save the file with a specific compression level.

private void SaveJpg(Image image, string filename, long compression)

{

   EncoderParameters encoderParams = new EncoderParameters();

   encoderParams.Param[0] = new EncoderParameter(

       System.Drawing.Imaging.Encoder.Quality, compression);

   ImageCodecInfo codecInfo = GetEncoderInfo(&quot;image/jpeg&quot;);

   File.Delete(filename);

   image.Save(filename, codecInfo, encoderParams);

}</pre></div></div><p>Now you can use this method to write a program that adjusts image compression. It&#39;s pretty fast, so you can even use a slider to try out different compression levels. Whenever the slider moves, save the image at the selected level in a temporary file and then display it. With a little experimentation, you can decide exactly how much compression you can get away with and still get an acceptable result.</p><p><em>Contributed by Rod Stephens, <a href="http://csharphelper.com/" data-popup="true">C# Helper</a></em></p>
<hr>
<p>As an internet marketer, I frequently come across client websites that have unoptimized images. I generally run into the following issues:</p>
<ul>
<li><p>  Using larger images and then resizing them using CSS or image (width/height) attributes.</p></li>
<li><p>  Using print quality images that are unoptimized for the web.</p></li>
<li><p>  Not lazy loading images on pages that have too many images.</p></li>
<li><p>  Using the wrong format of image, such as using PNG when JPEG would have resulted in a lower file size.</p></li>
</ul>
<p>Here are some image optimization tips and tools:</p>
<ul>
<li><p>  As far as PNG images go, one of best compression tools I have come across is PNGQuant, a lossy compressor. It also works well with images that have an alpha channel providing the smallest possible file size along with high-fidelity transparency.</p></li>
<li><p>  If you want even more compression, you further compress the image with PNGOutwin, a lossless compression software. In other words, it does not reduce the image quality.</p></li>
<li><p>  When it comes to the web, it&#39;s always best to save PNG images as PNG8, which is a lossy image format that supports only 256 colors.</p></li>
<li><p>  For JPEG, save the image using a lower-quality setting, somewhere around 80%-85%, and you can always go lower if the image isn&#39;t too blurry.</p></li>
<li><p>  Most JPEG images also carry EXIF data, which add a little bulk to the image. In addition to removing EXIF data, saving the image as a progressive JPEG (for images larger than 10kb) reduces the overall size, and also helps the image load faster when connections are slow. You can also try reducing the chroma information to reduce the image size further. Photoshop&#39;s &#39;Save for Web&#39; option allows you to play around with these options.</p></li>
<li><p>  An open source program that I love using to optimize JPEG images is RIOT, which has a range of minute settings for maximum compression for while maintaining overall quality.</p></li>
<li><p>  There are also a few open source options, such as mozjpeg by Mozilla and Guetzli by Google, which can reduce JEPG size by around 10% to 20%. But these need to be used through the command line (a GUI version isn&#39;t currently available).</p></li>
</ul>
<p><em>Contributed by Mukesh, <a href="http://orbitingweb.com" data-popup="true">OrbitingWeb</a></em></p>
<hr>
<p>Too many small business owners waste good money when it comes to trying to improve site performance. Image optimization is one way for site owners to improve performance without breaking the bank.</p><p>Some people assume that just because they use WordPress, their website is automatically SEO-optimized, and their images are too. There are many image optimization plugins available for WordPress, and if you&#39;re not using any of these, you&#39;re probably missing out on SEO and user experience.</p><p>Among the WordPress plugins, I recommend trying EWWW and imagify.io. These plugins have a variety of features such as  bulk image optimization, file type conversion, and automatic conversion of new uploads. Cloudinary&#39;s WordPress plugin is also great if you&#39;d like to get optimized images hosted in the cloud for you. A lost second on the web can cost you big in the bottom line.</p><p>See our <a href="https://www.mobiloud.com/blog/10-best-image-optimization-plugins-speed-wordpress-site/" data-popup="true">plugin comparison</a> for more details.</p><p><em>Contributed by Pietro Saccomani, Founder, <a href="https://www.mobiloud.com/" data-popup="true">MobiLoud</a></em></p>
<hr>
<p>Something that a lot of newcomers fail to understand when it comes to image optimization is the value of optimal resolution and quality. In a few image formats such as JPEG, which are lossy, some of the details are lost as a tradeoff for reduced size. In these cases, the lost details that are mostly irrelevant and would go unnoticed.</p><p>Another underestimated way to reduce size is picking the optimum resolution. Almost everyone knows that lowering the resolution reduces the size, but very few people understand how massive the difference in size is. This is because image size scales to the square of resolution dimensions.</p><p>All of these operations mentioned above can easily be achieved on the Unix command line using ImageMagick. To reduce the quality of an image (only for lossy image formats), run:</p><div class="code-holder"><div class="code_inner"><pre>convert &lt;input image location&gt; -quality &lt;quality desired (in precentage)&gt; &lt;output image location&gt;</pre></div></div><p>For example:</p><div class="code-holder"><div class="code_inner"><pre>convert input-image.jpg -quality 55 output-image.jpg</pre></div></div><p>To change the resolution of the image (also works on lossless formats):</p><div class="code-holder"><div class="code_inner"><pre>convert &lt;input image location&gt; -resize &lt;resolution&gt; &lt;output image location&gt;</pre></div></div><p>For example:</p><div class="code-holder"><div class="code_inner"><pre>convert input-image.jpg -resize 1280x720 output-image.jpg</pre></div></div><p>Mix and match quality reduction with resolution changes until you have an image with the detail you desire and the lowest possible size.</p><p><em>Contributed by Soham Kamani, Founder, <a href="http://sohamkamani.com" data-popup="true">sohamkamani.com</a></em></p>
<hr>
<p>Traditionally, icons on a web page have been drawn using bitmaps, which are often stitched together to deliver faster over the wire. However, bitmaps do not scale well on different screen resolutions, and this is a problem for responsive web design.</p><p>Font icons have proved to be a great alternative. Another common alternative is to use SVG, which means drawing scalable vector graphics. While there has been a good amount of research about optimizing network performance of font icons or SVGs, I could not find data that talks about the performance of these icons after they have been sent and rendered on the browser.</p><p>I wanted to check which type of icon allows 60 frames per second. The test candidates are:</p>
<ul>
<li><p>  Font icons: A font file embedded in an HTML page using the <code>&lt;link&gt;</code> tag, where the icon was usually created using a class.</p></li>
<li><p>  Inline SVG: SVG markup was used for the icon embedded into the web page.</p></li>
<li><p>  Background SVG: The SVG was inserted as data:uri in a class that was applied to repeated elements on the web page.</p></li>
</ul>
<p>The web page had each of these icons repeated multiple times, making the page long enough to scroll. Running each test multiple times, and watching trends for each of the 733+ icons should eliminate noise in the data. Basically, the performance order was, from best to worst: Font icons &gt; background SVG &gt; inline SVG.</p><p>From a pure performance perspective, font icons seem to perform the best. However, they cannot be manipulated like inline SVG icons, and are restricted to animating as a single unit. When using these recommendations on your site, they should be tested (using something like browser-perf).</p><p>Link to the full article: http://blog.nparashuram.com/2015/05/icons-font-inline-svg-or-background-svgs.html</p><p><em>Contributed by Parashum, Founder, <a href="http://blog.nparashuram.com/" data-popup="true">blog.nparashuram.com</a></em></p>
<hr>
<p>There are several ways to optimize images for online use:</p><p>First, creating multiple image sizes is highly recommended. Often you only need to display a thumbnail of an image, which would not require the full size. In such a case, creating a thumbnail copy of the original image save you load time, especially when creating a image gallery.</p><p>Take the time to decide which image format suits your need. You often won&#39;t need the maximum quality or any transparency options. When you do need transparency and high quality, go with PNG. If you need to display larger images without transparency, go with JPG.</p><p>When creating images, you can always try to play around with the quality settings, especially for JPG. Just try see how an image looks with a lower quality setting before choosing best quality. The differences are usually hardly visible, especially for images with less complexity and less colors.</p><p><em>Contributed by <a href="http://codester.com" data-popup="true">codester</a></em></p>
<hr>
<p>Videos don&#39;t necessarily have to be an impediment to improved web page performance. Here are some of the ways to optimize video files:</p>
<ul>
<li><p>  File size: A video&#39;s file size depends on the bitrate and other metadata attached to it. Data compression is one of the techniques to reduce the video file size without losing quality. FFmpeg, HandBrake, MPEG Streamclip are some of the compression tools that can be used to restructure the way pixel data is stored to make the final video optimized and lighter.</p></li>
<li><p>  File format: Different video file types store data in different ways, which is why a WebM video is lighter than an MP4 video. In addition, the browser may support only a few of the available formats, so ensure you aren&#39;t embedding videos that require extra plugins. Modern browsers support HTML5 formats like MP4, WebM and Ogg, which are is recommended.</p></li>
<li><p>  CDNs: CDNs can be used to stream video content so that it is available to the user instantaneously. Online Video Platform (OVP) providers offer services that handles video optimization to provide the user with seamless video streaming.</p></li>
<li><p>  Video streaming: Several new technologies make use of Adaptive Bitrate Streaming over HTTP to enable streaming; some of these include MPEG-DASH, HTTP Live Streaming (HLS), HTTP Dynamic Streaming (HDS), and so on. All these protocols are designed to stream videos from a regular HTTP server, making specialized media delivery servers redundant. The video stream is broken into smaller chunks of different bitrates that are ready for playback; a device trying to view the video file can pick the data stream as needed based on the bandwidth available.</p></li>
<li><p>  Optimizing page design for video: In addition to the format and data delivery of the video content, it&#39;s also important to optimize the web page design so that it doesn&#39;t hinder the user experience. Here are some points to consider when designing your website:</p></li>
<li><p>  Optimizing for mobile devices: The video must re-adjust along with the responsive design of the website; it should also detect the device orientation and display the video accordingly.</p></li>
<li><p>  Video size and placement: Using HTML or CSS to specify the exact width and height of the embedded video allows the browser to allocate the required bandwidth and avoid unnecessary overhead.</p></li>
<li><p>  Deferring videos: Embedded videos that are configured to auto-play requires the page to make additional requests for files and resources needed for video playback, which might slow down the page significantly. Deferring videos from loading till after the initial page load has completed frees up bandwidth.</p></li>
</ul>
<p>Multimedia content has become a necessity in engaging users and can improve conversion rates on your website. So there are more reasons to embed videos on your web page than there are disadvantages. There is no cost to performance if we optimize the page design, pick the right video format and utilize media delivery providers to handle video processing efficiently.</p><p><em>Contributed by Kameerath Kareem, Writer, <a href="http://blog.catchpoint.com/" data-popup="true">catchpoint</a></em></p>
<hr>
<p>When compressing your images, it&#39;s very important to make a proper balance between the image size and image quality. The quality of the image will decrease as the size decreases.</p><p>Here are a few different methods of optimizing/compressing your image size:</p>
<ul>
<li><p>  Optimizing images before uploading to the site: Optimizing your images before uploading them to your website may be time consuming, but it&#39;s the most effective of all methods.</p></li>
<li><p>  Offline tools for reducing image size: No matter on which platform or operating system your machine runs, you will easily find a free or paid tool according to your preference. Some recommended offline tools are: Photoshop, GIMP, Trimage, ImageOptim (MAC utility), PNGGauntlet and RIOT (Windows).In RIOT, you can preview and compare your final results with the original image, is very useful.</p></li>
<li><p>  Online tools for reducing image size: If you don&#39;t want to go through the hassle of downloading and installing the offline software on your computer, you can opt for online tools. Some recommended tools are: JPEGMini, PunyPNG, TinyPNG, Kraken.io.</p></li>
<li><p>  Optimizing images after uploading to WordPress: There are various WordPress plugins available, however, this method is not as efficient as optimizing images before uploading them to your blog. Some of the most popular plugins are: Smush.it, EWWW Image Optimizer, CW Image Optimizer, Imsanity, Hammy. In fact, WordPress has a default JPEG image compression setting for images uploaded to the WordPress media gallery, which compresses by 90% of the original quality. There is no way to change this setting from the admin panel. Read our <a href="https://www.wpblogcafe.com/how-to-change-the-default-wordpress-jpeg-image-compression/" data-popup="true">post</a> explaining how to configure this setting.</p></li>
</ul>
<p>With regards to image dimensions, the larger the dimensions the larger the image, which leads to slower page load. Don&#39;t depend on resizing the height and width of the images in your post editor, because the browser will still load the image with original dimensions and then resize it.</p><p>Therefore, you need to resize the image dimensions before uploading to your website. Check the content area width of your blog and resize images according to it. There are various tools for this purpose, such as PicResize, IrfanView, PicMonkey.</p><p><em>Contributed by Pankaj Kumar, <a href="https://www.wpblogcafe.com" data-popup="true">WPBlogCafe</a></em></p>
<hr>
<p>Whenever I start optimizing any website for performance, the biggest bottlenecks are non-optimized images, so I tend to start here. Luckily, it&#39;s easy to fix if you approach it systematically.</p><p>Here are three steps you should follow when preparing images for the web:</p>
<ol>
<li><p> Select the right image format: Broadly-supported image formats for the web are JPEG, PNG, and GIF. GIF is the only format that supports animations, but you should consider the <code>&lt;video&gt;</code> HTML tag and the WebM format for optimal performance. If you&#39;re displaying a still picture, this leaves you with the JPEG and PNG. The general rule of thumb is: Use PNG for illustrations, graphics, logos and all the images with only a few colors. Use JPEG for everything else: Pictures, Illustrations with gradients, and so on.</p></li>
<li><p> Downsize the images before uploading them to your server: Before your downsize your images, you need to know how your images will be displayed on your website in terms of pixel dimensions. If your content container is 1200 pixels wide, you should downsize your images to be 1200 px wide. If you want to provide the optimal experience for users with retina screens, consider providing 2x image resolution, in our case 2400px (in this case, you should use the srcset and sizes attributes of the <code>&lt;img&gt;</code> HTML tag).</p></li>
<li><p> Compress and optimize the images: The last step is to use an appropriate image compression algorithm to strip away as many bytes as possible. This one is the trickiest. It depends on your own preferences and it&#39;s the constant debate of what is more important to you: smaller file size or better quality?</p></li>
</ol>
<p>Instead of leaving you here, I want to share a sweet spot that serves as a good starting point for JPEG images. When exporting the image from your desktop software (i.e. Photoshop), save the image at the quality set to 90/100. Then run it through one of the online image optimization tools.</p><p>If your CMS of choice is WordPress, you can rely on WordPress to handle at least steps 2 and 3. We&#39;ve tested all leading solutions for WordPress in our &#39;Ultimate Guide to Image Optimization for WordPress&#39; (<a href="https://www.proteusthemes.com/blog/ultimate-guide-image-optimization-wordpress/" data-popup="true">more details</a>).</p><p><em>Contributed by Primoz Cigler, <a href="https://www.proteusthemes.com/" data-popup="true">ProteusThemes</a></em></p>]]>
      </description>
      <author>Gilad Maayan</author>
      <pubDate>Wed, 01 Nov 2017 13:44:15 +0000</pubDate>
      <link>https://cloudinary.com/blog/image_optimization_expert_roundup</link>
      <guid>https://cloudinary.com/blog/image_optimization_expert_roundup</guid>
    </item>
    <item>
      <title>How to Improve Your Shopify’s Store Loading Times using Cloudinary</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:770px;"><div class="content-img-inner-wrapper" style="padding-top: 55.06%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/Shopify_2000x1100.jpg" style="margin: 0 auto;display: block" /></div></div>
Having a commanding presence in e-commerce is very important for the average entrepreneur or merchant today. Building a brand for your business online can be tricky. It’s frustrating having HD images from your product photographer and not having the right tools to optimize the image size and delivery time without losing the quality of the image. This causes latency in your online stores and piles up bad experiences for your users, resulting in losing conversions and revenues.</p><p>It does not have to be that way ― with Shopify and Cloudinary, you are just one step away from having the perfect e-commerce store. In this article, you will learn the basics of creating your store with Shopify and integrating it with Cloudinary, so you can manage your images. </p><p>With Cloudinary managing your images, you are assured of optimized media content delivery which leads to improved performance, shorter website load times, and more conversion.</p><a class="anchor" name="what_is_shopify"></a><h2><a href="#what_is_shopify">What is Shopify?</a></h2><p><a href="https://www.shopify.com" data-popup="true">Shopify</a> is an e-commerce platform that enables you to set up your own online shop. It supports uploading products and setting up payments and shipping, among other activities.</p><a class="anchor" name="what_is_cloudinary"></a><h2><a href="#what_is_cloudinary">What is Cloudinary?</a></h2><p><a href="https://cloudinary.com/" data-popup="true">Cloudinary</a> is a SaaS offering that provides solutions for image and video management, including server or client-side upload, a huge range of on-the-fly image and video manipulation options, quick CDN delivery, and powerful asset management options.</p><p>Cloudinary enables web and mobile developers to address all their media management needs with simple bits of code in their favorite programming languages or frameworks, leaving them free to focus primarily on their own product&#39;s value proposition.</p><a class="anchor" name="getting_started_with_shopify"></a><h2><a href="#getting_started_with_shopify">Getting Started with Shopify</a></h2><p>To create a Shopify platform, follow this step-by-step process:</p><p><strong>1. Sign Up with Shopify</strong></p><p>Visit <a href="http://www.shopify.com/" data-popup="true">Shopify</a> and create an account using the signup form. Fill in the necessary details where required.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.02.55_PM_qzb86r.png" style="margin: 0 auto;display: block" /></div></div></p><p><strong>2. Start Setting Up Your Online Shop</strong></p><p>After signing up, you will be directed to your store admin screen. From there, you can modify what your store looks like, upload products, set up payments and shipping.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.05.10_PM_jzzyqq.png" style="margin: 0 auto;display: block" /></div></div></p><p><strong>3. Pick a Theme</strong></p><p>You can choose a theme from Shopify’s <a href="http://themes.shopify.com" data-popup="true">theme store</a>. Themes can be modified by editing their HTML and CSS files.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.05.38_PM_ptmkkv.png" style="margin: 0 auto;display: block" /></div></div></p><p>For a more detailed tutorial about how to build an online store with Shopify, check out this cool article <a href="https://websitesetup.org/build-online-store-shopify/" data-popup="true">here</a>.</p><a class="anchor" name="integrating_cloudinary_with_your_store"></a><h2><a href="#integrating_cloudinary_with_your_store">Integrating Cloudinary with your Store</a></h2><p>What’s a store without descriptive images? What’s your product if you can’t successfully manipulate images to tell your audience a convincing story? Even if you already took care of having the best images, how frustrating it can be if these are loaded so slowly and your potential customers leave the store before becoming real customers. You can solve all these using Cloudinary.  In addition to creating light-weight images that reduce the loading time of your page, Cloudinary’ offers other <a href="https://cloudinary.com/addons" data-popup="true">awesome features</a> from which you can benefit.. </p><p>To get our fetch URL, which we will need later, we’ll have to <a href="https://cloudinary.com/users/register/free" data-popup="true">sign up</a> for a free Cloudinary account:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 76.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/image_preview_bnjybd.jpg" style="margin: 0 auto;display: block" /></div></div></p><p>Cloudinary also offers a dashboard where you can manage your media contents that are uploaded to your cloud. You can also apply transformations to these images via the Media Library page on the dashboard.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 71.14%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/image_preview_1_r0pwes.jpg" style="margin: 0 auto;display: block" /></div></div></p><p>Bearing in mind that the integration is technical and requires editing our Shopify Theme code, let’s take the following steps to set up Cloudinary:</p><p><strong>STEP</strong> <strong>1</strong><strong>:     Edit your “settings_schema.json” file</strong></p><p>On the homepage of your store, navigate to:  <em>Online Store &gt; Themes &gt; Actions &gt; Edit Code &gt; Config.</em></p><p>Open the <code>settings_schema.json</code> file:</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.16.27_PM_xbg6te.png" style="margin: 0 auto;display: block" /></div></div></p><p>In between the very first &quot;[&quot; and the &quot;{&quot;, insert the following code into <code>settings_schema.json</code>. Then go to the next line and insert a comma right before the start of the next opening &quot;{&quot;:</p><div class="code-holder"><div class="code_inner"><pre>    {
      &quot;name&quot;: &quot;Cloudinary&quot;,
      &quot;settings&quot;: [
        {
          &quot;type&quot;: &quot;paragraph&quot;,
          &quot;content&quot;: &quot;Load all your images leveraging Cloudinary&#x27;s remote image Fetch for best page load performance.&quot;
        },
        {
          &quot;type&quot;: &quot;checkbox&quot;,
          &quot;id&quot;: &quot;enableCloudinary&quot;,
          &quot;label&quot;: &quot;Enable Cloudinary&quot;
        },
        {
          &quot;type&quot;: &quot;text&quot;,
          &quot;id&quot;: &quot;cloudinaryUrl&quot;,
          &quot;label&quot;: &quot;Cloudinary Fetch URL&quot;,
          &quot;info&quot;: &quot;Your Cloudinary Fetch url containing your domain, cloud name, and global transformations to apply to all images (ex:
          `\/\/res.cloudinary.com\/myAcct\/image\/fetch\/q_auto,f_auto,fl_lossy\/`).&quot;
        }
      ]
    }</pre></div></div><p><strong>STEP</strong> <strong>2</strong><strong>:     Add a New “Snippet”</strong></p><p>On your store’s homepage, navigate to:  <em>Online Store &gt; Themes &gt; Actions &gt; Edit Code &gt; Snippets.</em></p><p>Add a new snippet and name it  <code>cloudinary.liquid</code></p><p>Insert the following code into <code>cloudinary.liquid</code> and hit the <strong>Save</strong> button.</p><div class="code-holder"><div class="code_inner"><pre>    {% if img %}
            {%if settings.enableCloudinary and settings.cloudinaryUrl != blank %}
        {% assign baseUrl = settings.cloudinaryUrl %}
        {%if img contains &quot;?&quot; %}
          {% assign imgUrl = img | split: &quot;?&quot; %}
          {% assign fetchQuery = &quot;?&quot; | append: imgUrl.last | url_encode %}
          {% assign fetchUrl = imgUrl.first | append: fetchQuery %}
        {% else %}
          {% assign fetchUrl = img %} 
        {% endif %}
        {%if transformation and transformation !=blank %}
          {% assign imgTransformation = transformation | append: &#x27;/|&#x27; | prepend:&#x27;|/&#x27; | replace        :&#x27;//&#x27;,&#x27;/&#x27; %}
          {% assign baseUrl = baseUrl | append: &#x27;/|&#x27; | append: transformation | replace:&#x27;fetch        //&#x27;, &#x27;fetch/&#x27; %}
        {% endif %}
        {% assign imgUrl = baseUrl | append: &#x27;/https:&#x27; | append:fetchUrl | replace: &#x27;https:htt       p&#x27;,&#x27;http&#x27; | replace:&#x27;/|/&#x27;,&#x27;/&#x27; | replace:&#x27;//|&#x27;,&#x27;/&#x27; |
    replace:&#x27;/|&#x27;,&#x27;/&#x27; %}
        {{ imgUrl | img_tag: img_tag, img_class}}
      {% else %}
        {{img | img_tag: img_tag, img_class}}
      {% endif %}
    {% endif %}</pre></div></div><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.28.11_PM_gr4njj.png" style="margin: 0 auto;display: block" /></div></div></p><p><strong>STEP</strong> <strong>3</strong><strong>:     Configure Your Cloudinary Settings</strong></p><p>From the store homepage, navigate to:  <em>Online Store &gt; Themes &gt; Customize &gt; General Settings</em></p><p>Click on the <code>Cloudinary</code> section</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.29.50_PM_ufz3ra.png" style="margin: 0 auto;display: block" /></div></div></p><p>Tick the <code>Enable Cloudinary</code> checkbox</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.31.11_PM_rw9ttl.png" style="margin: 0 auto;display: block" /></div></div></p><p>Insert the Cloudinary fetch URL, which is below the input box and hit the <strong>Save</strong> button</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 70.43%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Screen_Shot_2017-10-09_at_6.35.18_PM_aothrb.png" style="margin: 0 auto;display: block" /></div></div></p><p>An example of the fetch URL would be something like the following:</p><div class="code-holder"><div class="code_inner"><pre>//res.cloudinary.com/demo/image/fetch/q_auto,f_auto,fl_lossy</pre></div></div><p>The <code>demo</code> parameter should be replaced with your Cloudinary cloud name.</p><p>You can read more about the <a href="https://cloudinary.com/blog/introducing_smart_cropping_intelligent_quality_selection_and_automated_responsive_images" data-popup="true"><code>auto</code> property</a> which applies global transformations to your images for optimization reasons</p><p><strong>STEP</strong> <strong>4</strong><strong>:     Update Your Section&#39;s Theme</strong></p><p>On the store homepage, navigate to:  <em>Online Store &gt; Themes &gt; Actions&gt; Edit Code &gt; Sections</em></p><p>Click on the section or sections that you want to update.</p><div class="code-holder"><div class="code_inner"><pre>    &lt;!-- from feature-row.liquid --&gt;

    &lt;div class=&quot;page-width feature-row&quot;&gt;
      {% capture image_layout %}
        &lt;div class=&quot;feature-row__item&quot;&gt;
          {% if section.settings.image != blank %}
          &lt;!-- replace the commented out code using your `cloudinary.liquid` snippet  --&gt;
          &lt;!-- {% capture img_id %}FeatureRowImage-{{ section.id }}{% endcapture %}
            {% capture wrapper_id %}FeatureRowImageWrapper-{{ section.id }}{% endcapture %}
            {%- assign img_url = section.settings.image | img_url: &#x27;1x1&#x27; | replace: &#x27;_1x1.&#x27;, &#x27;_{width}x.&#x27; -%}
            {% include &#x27;image-style&#x27; with image: section.settings.image, width: 545, height: 545, small_style: true, wrapper_id: wrapper_id, img_id: img_id %}
            &lt;div id=&quot;{{ wrapper_id }}&quot; class=&quot;feature-row__image-wrapper js&quot;&gt;
              &lt;div style=&quot;padding-top:{{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100}}%;&quot;&gt;
                &lt;img id=&quot;{{ img_id }}&quot;
                     class=&quot;feature-row__image lazyload&quot;
                     src=&quot;{{ section.settings.image | img_url: &#x27;200x200&#x27; }}&quot;
                     data-src=&quot;{{ img_url }}&quot;
                     data-widths=&quot;[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048]&quot;
                     data-aspectratio=&quot;{{ section.settings.image.aspect_ratio }}&quot;
                     data-sizes=&quot;auto&quot;
                     alt=&quot;{{ section.settings.image.alt | escape }}&quot;&gt;
              &lt;/div&gt;
            &lt;/div&gt;

            &lt;noscript&gt;
              {{ section.settings.image | img_url: &#x27;600x600&#x27;, scale: 2 | img_tag: section.settings.image.alt, &#x27;feature-row__image&#x27; }}
            &lt;/noscript&gt; --&gt;

          {% else %}
            {{ &#x27;image&#x27; | placeholder_svg_tag: &#x27;placeholder-svg&#x27; }}
          {% endif %}
        &lt;/div&gt;
      {% endcapture %}

      &lt;div class=&quot;feature-row&quot;&gt;
        {% if section.settings.layout == &#x27;left&#x27; %}
          {{ image_layout }}
        {% endif %}

        &lt;div class=&quot;feature-row__item feature-row__text feature-row__text--{{ section.settings.layout }}&quot;&gt;
          {% if section.settings.title != blank %}
            &lt;h2 class=&quot;h3&quot;&gt;{{ section.settings.title | escape }}&lt;/h2&gt;
          {% endif %}
          {% if section.settings.text != blank %}
            &lt;div class=&quot;rte-setting featured-row__subtext&quot;&gt;{{ section.settings.text }}&lt;/div&gt;
          {% endif %}
          {% if section.settings.button_label != blank and section.settings.button_link != blank %}
            &lt;a href=&quot;{{ section.settings.button_link }}&quot; class=&quot;btn&quot;&gt;
              {{ section.settings.button_label | escape }}
            &lt;/a&gt;
          {% endif %}
        &lt;/div&gt;

        {% if section.settings.layout == &#x27;right&#x27; %}
          {{ image_layout }}
        {% endif %}
      &lt;/div&gt;
    &lt;/div&gt;</pre></div></div><p>Remove the original image code. For example:</p><div class="code-holder"><div class="code_inner"><pre>    {{section.settings.image | img_url: &#x27;600x600&#x27; | img_tag: section.settings.image.alt, &#x27;feature-row__image&#x27; }}</pre></div></div><p>Next, assign a new “img” variable to the Shopify CDN hosted image URL.</p><div class="code-holder"><div class="code_inner"><pre>    {% assign img = section.settings.image | img_url: &#x27;600x600&#x27; %}</pre></div></div><p>Then, include your Cloudinary snippet and pass the new <code>img</code> variable and optionally pass in  additional Cloudinary transformations to further customize your images for your specific templates, in addition to any global transformations you may have configured:</p><div class="code-holder"><div class="code_inner"><pre>{% include &#x27;cloudinary&#x27;, img:img, transformation: &#x27;w_300,h_300,c_fill,g_auto&#x27;, img_tag:
section.settings.image.alt, img_class: &#x27;feature-row__image&#x27; %}</pre></div></div><p>Congratulations!  You&#39;re images are now loading through Cloudinary</p><a class="anchor" name="few_points_to_take_away"></a><h2><a href="#few_points_to_take_away">Few Points to Take Away</a></h2>
<ol>
<li> One click enable/disable of the Cloudinary integration - ideal for performance A/B testing on demand.</li>
<li> The integration uses Cloudinary’s 3rd party proxy &quot;Fetch&quot; protocol so you can still use your Shopify media library as is and we&#39;ll import, manipulate and deliver all your images via Cloudinary automatically.</li>
<li> You&#39;ll have access to both Global transformation settings (common transformations for all assets) as well as location specific / template specific transformation settings.  The only downside is that you&#39;ll need to update your image references in your existing snippets / templates as shown in the integration guide.  However, you also have full control to edit the integration to your needs using this version as a starting point.</li>
</ol>
<a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>Image optimization in websites is a very important feature that cannot be overlooked. The same can be said for online stores. Having a store that displays its content in the best possible way and display it immediately will not only speak well of your brand, but will play a huge role in dictating sales volume and other important factors in the long run. Some of these factors include customer acquisition rate, conversion rate, and whether or not they keep visiting your site after the first few experiences. For a more detailed overview on how to optimize images on your websites, you can check out this <a href="https://cloudinary.com/blog/image_optimization_in_wordpress" data-popup="true">article</a> by <a href="https://twitter.com/unicodeveloper" data-popup="true">Prosper Otemuyiwa</a> .</p>]]>
      </description>
      <author />
      <pubDate>Mon, 30 Oct 2017 18:44:47 +0000</pubDate>
      <link>https://cloudinary.com/blog/how_to_improve_your_shopify_s_store_loading_times_using_cloudinary</link>
      <guid>https://cloudinary.com/blog/how_to_improve_your_shopify_s_store_loading_times_using_cloudinary</guid>
    </item>
    <item>
      <title>Cloudinary Offers Support for sonar Tool</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:1540px;"><div class="content-img-inner-wrapper" style="padding-top: 55.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/Cloudinary_Sonar_2000x1100_v1-2.png" style="margin: 0 auto;display: block" /></div></div></p><p>Cloudinary is now supporting the <a href="https://sonarwhal.com/" data-popup="true">sonar</a> tool, an open source platform that aims to bring together best practices for web developers.</p><a class="anchor" name="what_is_sonar"></a><h3><a href="#what_is_sonar">What is sonar?</a></h3><p>sonar is a linting tool for the web that was developed out of Microsoft&#39;s Edge team. The code for the project was donated to the <a href="https://js.foundation/announcements/2017/06/22/sonar-js-foundation-welcomes-newest-project" data-popup="true">JS Foundation</a> and development is open and looking for input from anyone in the web community, such as browser vendors, web experts and developers.</p><p>There are four primary goals for sonar:</p>
<ul>
<li><p>Use the community to identify key web development best practices</p></li>
<li><p>Provide tools that help web developers write the best possible code</p></li>
<li><p>Help identify issues in existing code that do not adhere to current best practices</p></li>
<li><p>Promote community tools and services that drive web development best practices</p></li>
</ul>
<p>Currently sonar supports jsdom, Chrome and Edge 15 web browsers, and expect to add support for Firefox soon. sonar is also integrating other best-in-class tools and services, such as aXe for accessibility and SSL Server Test for checking the certificate configuration.</p><a class="anchor" name="cloudinary_helps_assess_site_speed"></a><h3><a href="#cloudinary_helps_assess_site_speed">Cloudinary Helps Assess Site Speed</a></h3><p>sonar&#39;s <a href="https://sonarwhal.com/scanner" data-popup="true">scanner</a> tool currently tests the <a href="https://sonarwhal.com/docs/user-guide/rules/index.html" data-popup="true">following</a> for web sites:</p>
<ol>
<li><p> Accessibility of the website to serve users with impairments or disabilities</p></li>
<li><p> Interoperability with of the site with different browsers</p></li>
<li><p> Performance for fast page load time</p></li>
<li><p> Progressive Web Apps tests the interactions of the site with iOS touch icon and mobile software that supports the <a href="https://w3c.github.io/manifest/" data-popup="true">web app manifest file</a>.   </p></li>
<li><p> Security for various disallowed headers and vulnerabilities.</p></li>
</ol>
<p>Cloudinary is providing some functionality under the Performance section of sonar scanner that was originally built for Cloudinary&#39;s <a href="https://webspeedtest.cloudinary.com/" data-popup="true">website speed</a> assessment tool. Specifically for sonar, Cloudinary is providing advanced algorithms that demonstrate how changes - such as image size, format, quality and encoding parameters - can deliver significant reductions in file size while maintaining perceived quality and ultimately making websites run faster in any browser.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 48.14%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/ERe5RlZaCI_wsE6Oz3AzLDFeuUGt1hYFtXNTwrfqKilGnu1S9XNj3h2xVQUePGn-lGJ4xn_MpDV8EPbS8bMD45DO91Hs_VVVT2ACbikcVtzUANGoW9K48tHwMo-UbIJU9l7y_P8l.png" style="margin: 0 auto;display: block" /></div></div></p><p>The results will display/drill into each image that could benefit from an optimization and what the estimated compression savings could result in.</p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 9.71%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/E_TGsjc5O5Ozawl3L5pNstrPGjrc1mXuBUUrhZlW3QgE8NqlYfL0Z1rAHz8x_9A0Iv_B3wVrRKgYAuPqkoLVhyGmj_6B4NagqS2QAvpzK4vKmLl3EVG8eGsKHht3qdoBRUMK_Yr-.png" style="margin: 0 auto;display: block" /></div></div></p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 11.57%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/0O7rML928-fniTO75heb3XR5TDxW9AJJOE6miJoivZhm3JqS0dPnFjfJHkx2vr00LtCxMuf0KP-_YGzSmOgTxb95Dhg_-yGo3wqY3s5cnc-EzxgqB_AVWY72QGLBRYHcMgmuM_tE.png" style="margin: 0 auto;display: block" /></div></div></p><p><div class="content-img-outer-wrapper" style="max-width:700px;"><div class="content-img-inner-wrapper" style="padding-top: 38.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/B_zfUYNSVApBiHsjih0VBcDtWOUfbVWF10WjZSCxPP4uKfpnizw-hnZL-Ot5po63m3ki9ysgWuKJKtlPyI_8X3DumgmkUB3FK3RVztKanBvqA6vLIoOaPlK1bZ82xTwJBqE34-WD.png" style="margin: 0 auto;display: block" /></div></div></p><p>You can use this rule in the online site <a href="https://sonarwhal.com/scanner" data-popup="true">scan</a> or via the <a href="https://sonarwhal.com/docs/user-guide/rules/image-optimization-cloudinary.html" data-popup="true">command line</a> as part of the latest version of sonar (0.12.2).</p><p>We are very excited to participate in the program with the sonar team. We hope all Cloudinary users and community members will visit the sonar project, and take a look to see just how valuable it could be in helping maintain best practices for web development. For more information about sonar, read through their blog post on the scanner tool <a href="https://blogs.windows.com/msedgedev/2017/10/25/introducing-sonar-site-scanner/" data-popup="true">here</a>, check out their <a href="http://sonarwhal.com" data-popup="true">website</a>, <a href="https://github.com/sonarwhal" data-popup="true">GitHub repo</a> or follow them on Twitter at <a href="https://twitter.com/narwhalnellie" data-popup="true">@narwhalnellie</a>.</p>]]>
      </description>
      <author />
      <pubDate>Wed, 25 Oct 2017 16:07:29 +0000</pubDate>
      <link>https://cloudinary.com/blog/cloudinary_offers_support_for_sonar</link>
      <guid>https://cloudinary.com/blog/cloudinary_offers_support_for_sonar</guid>
    </item>
    <item>
      <title>How to Prevent WordPress from Generating Multiple Images</title>
      <description>
        <![CDATA[<p><div class="content-img-outer-wrapper" style="max-width:1540px;"><div class="content-img-inner-wrapper" style="padding-top: 55.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_770,c_fill/dpr_auto/WP_Multiple_Images_2000x1100.jpg" style="margin: 0 auto;display: block" /></div></div></p><p>In this tutorial, we&#39;re going to learn how to prevent WordPress from generating multiple (resized) versions of an image. As of WordPress 4.8.1, with the default Twenty Seventeen theme, WordPress will generate six additional resized versions of a single image. I&#39;ve tested it on a clean installation, and here&#39;s a screenshot to prove it.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 39.07%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/kGuvVGxyq_UuCBE49avgPwdJeCGCEgt9U0_xqDE1gGBwKDvQVQwu0gOCOS0054BJ-KysqUMWVEgpRyV4Fl7T0r3E6AmcZ8R8oL-IM-qFpb-EtPEqZJoWwD3r8bEx3LCYGNxhjIyH.png" style="margin: 0 auto;display: block" /></div></div></p><p>WordPress 4.8.1, with the Twenty Seventeen theme, generating six resized versions for every image uploaded.</p><p>Generating this many images might negatively affect your WordPress host&#39;s performance. Specially while taking backups. How? Let me explain.</p><p>In the example above, we see that there&#39;s a 99.3 percent increase in the amount of storage used for uploading a single image. That&#39;s almost twice the size.</p><p>While most web hosts provide unlimited storage, this would significantly increase the backup size and duration.</p><p>Cloudinary users would know that one can directly obtain a resized version of an image using Cloudinary&#39;s <a href="http://cloudinary.com/documentation/image_optimization" data-popup="true">image optimization</a> features, simply by adding parameters in the image URL. But that&#39;s a story for another day.</p><a class="anchor" name="why_does_wordpress_generate_multiple_resized_versions_of_each_image"></a><h3><a href="#why_does_wordpress_generate_multiple_resized_versions_of_each_image">Why Does WordPress Generate Multiple Resized Versions of each Image?</a></h3><p>Good question! First, it&#39;s important to note that both WordPress and the active theme generates multiple resized versions of an uploaded image.</p><p>The smaller version of the image is served to a mobile device, the larger to a desktop device, and so on. The active theme might have custom post types, (a popular example being the portfolio), which could require certain fixed dimensions of the image.</p><p>Responsive images was introduced in WordPress 4.4. It scans the device&#39;s viewport and serves the optimal dimension of the image to the browser. This approach reduced the size of the image to be loaded, resulting in faster loading times and better user experience.</p><a class="anchor" name="it_s_ok_to_have_multiple_versions_of_uploaded_images"></a><h3><a href="#it_s_ok_to_have_multiple_versions_of_uploaded_images">It&#39;s OK to Have Multiple Versions of Uploaded Images</a></h3><p>Here&#39;s the situation - and I cannot stress this enough - the backup size/time issue described above is not that bad. Rather, for a regular WordPress blog, it is absolutely fine  to have multiple versions of the uploaded images.</p><p>Here&#39;s why:</p><p>WordPress is an intricate system with a lot of moving parts. Removing a theme&#39;s default behavior (in our case, generating multiple versions of the behavior) might not be the best idea. It could result in broken images across your site - both in the desktop and mobile responsive versions - inadvertently hurting image SEO and hampering the user experience.</p><p>Therefore, it requires in-depth understanding of theme&#39;s functioning and experience in WordPress development. This tutorial should not be used by intermediate WordPress users on a live site.</p><p>Side Note: If you&#39;re like me and want to take things apart in preset to understand them - be my guest. But please use an experimental WordPress installation!</p><a class="anchor" name="how_to_prevent_wordpress_from_generating_multiple_image_versions"></a><h3><a href="#how_to_prevent_wordpress_from_generating_multiple_image_versions">How to Prevent WordPress From Generating Multiple Image Versions</a></h3><p>In order to prevent broken links, I&#39;ve structured this tutorial in three phases.</p>
<ul>
<li><p>  Phase One: Identifying the images we could safely prevent from generating further</p></li>
<li><p>  Phase Two: Committing the changes in two parts:</p></li>
<li><p>  Part 1: Changing the core WordPress settings</p></li>
<li><p>  Part 2: Editing the active theme&#39;s functions.php file</p></li>
<li><p>  Phase Three: Looking at the methods one could use to delete the existing resized images.</p></li>
</ul>
<a class="anchor" name="phase_one_identifying_images_to_be_removed"></a><h2><a href="#phase_one_identifying_images_to_be_removed">Phase One: Identifying Images to be Removed</a></h2><p>In this phase, we identify the images that can be safely removed, without breaking the website. As a reference, we&#39;ll use the same image uploaded in the beginning of this tutorial.</p><p>The first step is to prepare a list of all the post types you are currently using or might use in the future. You will need to identify the corresponding image sizes for each post type. For instance, if you plan to use the portfolio layout of a multipurpose theme, you should retain that image size. However, if you prevent WordPress from generating this particular image size, you might not notice it now. But the moment you use portfolio post type, you would see broken images.</p><p>Before you can proceed with this phase, you need to be absolutely certain about the dimensions of the image you want to use in your site.</p><a class="anchor" name="would_this_affect_responsive_images"></a><h3><a href="#would_this_affect_responsive_images">Would This Affect Responsive Images?</a></h3><p>As I mentioned earlier, WordPress&#39; default responsive property enables you to serve different sizes of the same image, based on the visitor&#39;s viewport. In other words, a smaller image size would be served to a visitor from a mobile browser and a larger image size would be served to a visitor from the desktop browser.</p><p>Preventing WordPress from generating multiple images might have a negative impact on performance and user experience.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 39.07%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/Hjb96PoigZgMbLU97OhsT4tVg6wTFDnqNYl3296HFx47WoXZ2KlwL3h3hqZsNI1G8fzYGJlJwa8G5G_5wSnt4qB6OIX0n7Jlok86KYuU2FkUiIcxGWYYtn0yqMLlr_FKzBBVmBdP.png" style="margin: 0 auto;display: block" /></div></div></p><p>Size comparison of resized images in WordPress</p><p>Let&#39;s say you have prevented WordPress from generating any additional image sizes.</p><p>The smaller size of the image would never be generated, and only the original image would exist. In our case, the original image&#39;s size is 544KB. The same image would be served to a visitor from a mobile browser or a desktop browser.</p><p>Now let&#39;s say you did not prevent WordPress from generating additional image sizes. Different versions of the image would exist - including small, medium, large. Only in this case, the smaller sized version of the image would be served to the mobile browser. The size of the smaller image is 68KB, which is 87.5 percent smaller than the original image, which equates to an 87.5 percent bandwidth saving that would lead to a faster loading time and better user experience.</p><p>These savings are possible if you simply left WordPress alone to do its job!</p><p>Not to mention if you&#39;re using Cloudinary, you would easily be able to generate browser-dependent optimized images (in any resolution), simply by adding parameters to the image request URL. If you&#39;re a WordPress developer looking to implement a scalable, content delivery network- (CDN) powered, on-demand image transformation and optimization in your WordPress site, you should check out Cloudinary.</p><p>On the other hand, some multipurpose themes generate excessive number of images, which aren&#39;t really required at all times. One might only be using the homepage and the blog layout of a certain multipurpose theme. In such cases, you could identify the image sizes you need and safely do away with the ones you would not need.</p><a class="anchor" name="what_about_featured_images"></a><h3><a href="#what_about_featured_images">What About Featured Images?</a></h3><p>A blog post&#39;s featured image visually communicates the premise of the article, and increases click rate, readership and shareability. In other words, featured images are super important.</p><p>Based on your blog&#39;s homepage design, you might have a smaller sized version of the featured image used in the home page, or the blog pages. However, in the individual article view, you might be using a large version of the featured image. Most Medium-styled themes use this technique. In such a case, you might want to prevent WordPress from generating custom image sizes, except the featured image.</p><p>This is where things get tricky. Since we all use different WordPress themes, each theme will have its own unique code. It would be quite difficult for this tutorial to suggest a code change for each theme.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 81.79%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/sc_qLmeJptzrHXRlTfyx7zt59acXZY7ri_3BeGXbqV6ZHcB1V976BZj46dleTr0-eL5IhbBSonls9FEWmVuwd8ZlmQyCnf-l9mefOYtMp39nF_AeDHaYONSz1lZ4xl5Zch1D-eYA.png" style="margin: 0 auto;display: block" /></div></div></p><p>Sample code to create custom image sizes in WordPress. Credits: WPShout</p><p>Rather, it would be much simpler if we used the method outlined by this <a href="https://wpshout.com/wordpress-custom-image-sizes/" data-popup="true">excellent article</a> from WPShout. Read the bit under &quot;Adding WordPress Custom Image Sizes in function.php&quot; to create you own custom featured image sizes.</p><p>At the end of phase one, you have identified the images that you would want to remove, i.e. prevent WordPress from further generating these image sizes.</p><a class="anchor" name="phase_two_preventing_wordpress_from_generating_custom_image_sizes"></a><h2><a href="#phase_two_preventing_wordpress_from_generating_custom_image_sizes">Phase Two: Preventing WordPress from Generating Custom Image Sizes</a></h2><p>We&#39;ll divide this phase into two parts. In the first part, we&#39;ll look at changing the default WordPress settings. The second part will deal with modifying the theme&#39;s functions.php file.</p><a class="anchor" name="part_one_changing_wordpress_media_settings_to_prevent_generation_of_custom_images"></a><h3><a href="#part_one_changing_wordpress_media_settings_to_prevent_generation_of_custom_images">Part One - Changing WordPress&#39; Media Settings to Prevent Generation of Custom Images</a></h3><p>This part is fairly simple.</p><p>1. Login to your WordPress dashboard and go to Settings &gt; Media.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 66.21%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/sLCOvY2YzBwV6jsGhpFrTFJ2a0lAJOfYerS9Rhm9UpC85fW4CDL6wcU-hUx6anGpxbqJ6ZAAkgp7TC1XeWGDmIWKiT6Ua3UZvFCK55NsGyWqh9g-4vAilSunwR1f-49qBXGnDEoS.png" style="margin: 0 auto;display: block" /></div></div></p><p>Default WordPress Image sizes</p><p>You&#39;ll see the default sizes WordPress resizes each image. To prevent WordPress from generating these image sizes, simple change the values to 0.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 67.71%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/oa0QXWHcupoRAmsooGyBMy2G_3B0ZhZT0Kiza7RQ4jSmMGT5ZQjT_Io6tFUaSS-9q9ZuHscxjfAs--aiv8koYNmcOKdOppnAFcN3TEr_7s9nER1whCjYGdMO3yqeYFV4ePAPIqgM.png" style="margin: 0 auto;display: block" /></div></div></p><p>Preventing the WordPress core from generating multiple image sizes</p><p>Let&#39;s put this technique to test now. I&#39;ll upload another image in WordPress and check whether the images are being generated. The uploaded image is night shot of the NYC skyline, with a resolution of 5760x3840 (22 MP).</p><p>Let&#39;s see how many images are generated.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 43.5%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/6wiL3qwbM585Ebjtq-DaPUKqXoCBraB46XoU6-jGIkfMZ2a5IHIrpfKC9Nta0_KZGZu0QCuSh6nMxQm_ty9aqUrd5e_3stAwsnQE_36DQCZSVuIS12zNXig7wcKsqRnu65fgZGJa.png" style="margin: 0 auto;display: block" /></div></div></p><p>Before and after effect of preventing WordPress from generating resized images.</p><p>Yes, it works! You would notice that three images are not generated - exactly the ones that we disabled in the last step.</p>
<blockquote>
<p>On a separate note, when this image is uploaded to Cloudinary, it can be retrieved in any resolution by simply changing a single parameter. When a browser requests an image, Cloudinary detects the browser type (Chrome, Firefox, etc) and serves the most optimized version of that image, which is supported by that bowser.</p></blockquote>
<a class="anchor" name="part_two_modifying_the_theme_s_functions_php"></a><h3><a href="#part_two_modifying_the_theme_s_functions_php">Part Two - Modifying the Theme&#39;s functions.php</a></h3><p>Now let&#39;s look at changing the active theme&#39;s settings, in order to prevent it from generating additional images. Here it&#39;s important to reiterate that you should do this only if you are absolutely certain about how the active theme displays images in various posts and pages.</p><p>In our case, the Twenty Seventeen theme generates three custom images. After we disabled the WordPress core settings from generating resized images, there were three images that we still generated. This was done by the active theme. Depending on the theme, this number would vary. Most multipurpose themes use more than five custom image dimensions.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 38.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/JmO9p_8JmmW6567ppUpLXE0qiLfH1yl-nQzvXkQeGfmSNCnH1EvN4wFsI7SUG0X5VKOMI8ROugK50U5Owlnh1Ym4MUz6h_NT1EetV-NLRCn9e4c3q7aASE0VYF_6EcQLU5X1-3wp.png" style="margin: 0 auto;display: block" /></div></div></p><p>Custom image sizes generated by WordPress</p><a class="anchor" name="how_to_edit_a_wordpress_theme_s_functions_php_from_the_wordpress_dashboard"></a><h3><a href="#how_to_edit_a_wordpress_theme_s_functions_php_from_the_wordpress_dashboard">How to Edit a WordPress Theme&#39;s functions.php from the WordPress Dashboard</a></h3><p>Launch your WordPress dashboard, go to Appearance &gt; Editor and click on Theme Functions, as shown in the screenshot below:</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 67.14%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/F8hS_H71UsI0XHUtYMOfObLZGsfbtBjiJdSwSsfDj1tkg59WgUn37FhsgukC5yiUpn7P9aM8eH8LUUEOB9C6fXDkJ0oKcwknenoKrfeiX-nkVxMQ9EBp30pme7Ycm9azozhneXZT.png" style="margin: 0 auto;display: block" /></div></div></p><p>How to navigate to Theme Functions using the WordPress Editor</p><p>Next, we want to find all occurrences of the two functions and delete them. It&#39;s always a good practice to comment out a piece of code, rather than deleting it. This gives the developers a chance to investigate (in case something goes wrong) and makes it easier to revert the changes.</p><p>The first function we want to disable is the add<em>image</em>size() function. This function is used for generating additional images sizes by the theme. The second function we want to disable is called set<em>post</em>thumbnail_size(). Doing this would stop your theme from generating post thumbnail size in WordPress.</p><p>We need to comment out all occurrences of these functions. To do this, simply use your browser&#39;s Find utility. Press Ctrl+F (or Cmd+F on a Mac) and type add<em>image</em>size. Your browser will highlight all occurrences of this text in the website.</p><p>Once you find these lines, add &#39;//&#39; at the beginning to comment them out.</p><p>Similarly, find all occurrences of set<em>post-thumbnail</em>size and turn them into comments.</p><p>The following screenshot highlights the same.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 49.0%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/px74-VKi4qazj2PlyzlN7nRFYfAunnq_arQljLmyYYe-3pomifhiu9OXN21bpvj44YRzas-DUJczAHlJnDbEHyvY2cd7uVum2-qb2j8CD4bei9dPuyDF1EQplMa6ccxNz6gbAALw.png" style="margin: 0 auto;display: block" /></div></div></p><p>Commenting out the add<em>image</em>size() function in a theme&#39;s functions.php file</p><p>Once you&#39;ve commented the lines, remember to save the settings.</p><p><div class="content-img-outer-wrapper" style="max-width:1400px;"><div class="content-img-inner-wrapper" style="padding-top: 37.14%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_700,c_fill/dpr_auto/aqet74_KVedFRkNdUvzJ7lB5fdXW_vK4nQ5RLB-CEMeeSYQL0ZDrulaRNLDVpIdCQUOQohJ1BohdlFttBdOB8U2ZbVAlwU4MzCXoppBMJhr6dj4u0RWjJxBYR-KqhHUaJ-IflWL0.png" style="margin: 0 auto;display: block" /></div></div></p><p>How to save settings in the theme&#39;s functions.php file from the WordPress dashboard</p><p>In our example, the Twenty Seventeen theme did not use the set<em>post</em>thmbnail_size() function. Upon disabling these functions, the additional images were not generated by WordPress.</p><a class="anchor" name="phase_three_deleting_old_images"></a><h2><a href="#phase_three_deleting_old_images">Phase Three: Deleting Old Images</a></h2><p>Depending on how long you&#39;ve had your WordPress blog or the number of images uploaded, you could have multiple versions of each image in your media library. If you are certain about the image sizes you don&#39;t require, you can safely delete them.</p><p>There are a couple of ways of batch deleting images from WordPress.</p><a class="anchor" name="batch_deleting_images_via_ssh"></a><h3><a href="#batch_deleting_images_via_ssh">Batch Deleting Images via SSH</a></h3><p>This method works if you have SSH terminal access to your WordPress host. While most shared or managed WordPress hosts do not allow this process, it is the fastest one, provided you&#39;ve used Linux/UNIX before. It uses the classic find and delete feature in the bash shell.</p><p>First, we&#39;ll navigate to the WordPress Media directory, i.e. /wp-content/uploads directory and execute the find and delete function.</p><p>We need know the (i) resolution and (ii) extension of the images we want to delete.</p><p>For example, to delete all the 100x100px JPG images, the command would be:</p><p>find . -name &quot;*100x100.jpg&quot; -type f -delete</p><p>This command would recursively delete all JPG images ending with 100x100 in the filename. Check out this <a href="https://askubuntu.com/a/377442" data-popup="true">helpful AskUbuntu answer</a> for more info on the same.</p><p>We can repeat this process for each resolution we want to remove.</p><a class="anchor" name="batch_deleting_images_via_ftp"></a><h3><a href="#batch_deleting_images_via_ftp">Batch Deleting Images via FTP</a></h3><p>FTP is one of the easiest ways to batch delete files, albeit a bit time-consuming. Simply connect to your WordPress host using your preferred FTP client (we&#39;ll use FIleZilla in this tutorial).</p><p>Navigate to the public_html/wp-content/uploads directory.</p><p>From FileZilla&#39;s main menu, select Server &gt; Search Remote Files.</p><p>In the new dialog box, fill in the following information, as shown in the screenshot below.</p><p><div class="content-img-outer-wrapper" style="max-width:800px;"><div class="content-img-inner-wrapper" style="padding-top: 70.75%;"><img src="https://cloudinary-res.cloudinary.com/image/upload/w_400,c_fill/dpr_auto/N0pFusB_K4T-exh4i-hJYWmdReodvz0LaTXsElZUeGEICCWGy1CJ8ZJl3YJw1PenKOw8HztftjSar09Xwh0S4jEqBCNIZ6GMoy2iDmfAAHamhw6pYRRlXqmnlUXTBEvWPXh9qvTQ.png" style="margin: 0 auto;display: block" /></div></div></p><p>Recursively search and delete images in WordPress via FTP using FileZilla</p>
<ol>
<li><p> The Search directory should be the uploads folder</p></li>
<li><p> You can add multiple parameters to the search query. In our case, we want to remove all images with 100x100 resolution. Hence, we&#39;ve selected that the filename should contain the phrase 100x100. In case you wanted to delete only JPG files (optional), you could add another parameter, which mentions that the filename should end with jpg.</p></li>
<li><p> Once the parameters are defined, click on Search</p></li>
<li><p> FileZilla will query all the folders under the uploads directory and return the relevant results.</p></li>
<li><p> Select the files, right-click and click on Delete.</p></li>
</ol>
<p>That&#39;s it! Filezilla will delete all the files one-by-one.</p><a class="anchor" name="wrapping_up"></a><h2><a href="#wrapping_up">Wrapping Up</a></h2><p>Preventing WordPress from generating images is a delicate task, which, if done improperly, could lead to broken image links across your site. You might save a few minutes on the backup time, but you  run the risk of hampering the user experience. Remember, broken images indexed on Google might lead to lower SEO scores, which might affect your organic traffic and SERP ranking.</p><p>However, if you are absolutely certain about the image resolutions you want to use, you can prevent WordPress from generating additional/unwanted image sizes. There are two ways to do this. First you can change WordPress&#39; default Media settings. The second step is to investigate the active theme&#39;s functions.php and commenting out the line of code that call the add<em>image</em>size() and set<em>thumbnail</em>post_size() functions.</p><p>Finally, if you want to delete the existing images that you no longer wish to use, you can delete them via FTP or SSH. Phase three of this tutorial describes the matter in depth.</p>
<blockquote>
<p>On a separate note, if you are running an image-heavy website, such as a photo-blog or a travel blog with <a href="http://cloudinary.com/blog/cloudinary_upgrades_image_management_and_optimization_for_thrillophilia" data-popup="true">user generated content</a>, a dedicated image optimization and delivery solution would do wonders to your user experience.</p></blockquote>
<p>Cloudinary is the perfect solution, thanks to it&#39;s on-the-fly image optimization and transformation capabilities. Plus its multi-tier content delivery network delivers images in the shortest time possible to your website visitors. Manually resizing and optimizing images are a thing of the past, thanks to Cloudinary&#39;s range of on-the-fly transformation features.</p><p>What are your thoughts on WordPress generating multiple image sizes? Did this tutorial change your mind about altering image sizes? Let us know in the comments below!</p><p>*Originally posted on <a href="https://www.loudtechie.com/how-to-prevent-wordpress-from-generating-multiple-image-sizes/" data-popup="true">Loud Techie</a></p>]]>
      </description>
      <author />
      <pubDate>Mon, 23 Oct 2017 23:07:08 +0000</pubDate>
      <link>https://cloudinary.com/blog/how_to_prevent_wordpress_from_generating_multiple_images</link>
      <guid>https://cloudinary.com/blog/how_to_prevent_wordpress_from_generating_multiple_images</guid>
    </item>
    <item>
      <title>How to automatically tag images with Amazon Rekognition </title>
      <description>
        <![CDATA[<p><a href="https://res.cloudinary.com/demo/image/upload/v1502190887/Rekognition_tagging_blog.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:2000px;"><div class="content-img-inner-wrapper" style="padding-top: 55.0%;"><img alt="Auto tagging with Rekognition" src="https://res.cloudinary.com/demo/image/upload/v1502190887/Rekognition_tagging_blog.jpg" style="margin: 0 auto;display: block" title="Auto tagging with Rekognition" /></div></div></a></p><p>Knowledge is power. And if you allow your users to upload images, you also probably want to better understand what their images contain. Whether a photo is of a building, people, animals, celebrities, or a product, image processing and analysis can assist in further comprehension. The benefits of this knowledge can go beyond &quot;merely&quot; categorizing your content and making your image library searchable: drawing insights from user generated content can be very useful! What better way to learn more about your users than to analyze the images they upload and find out what they care about and then have the ability to display relevant content to them according to their interests or even match them with other users that share similar interests.</p><p>Analyzing the contents of a photograph would be a huge time sink if performed manually on a lot of images. Enter <a href="https://aws.amazon.com/rekognition/" data-popup="true">Amazon Rekognition</a>, a service that uses deep neural network models to detect and tag thousands of people, objects and scenes in your images, and lets you easily build powerful visual search and discovery into your applications. </p><p>Cloudinary has integrated two Amazon Rekognition add-ons into its image management and manipulation pipeline: the <a href="#amazon_rekognition_categorization">Amazon Rekognition Auto Tagging</a> add-on and the <a href="#amazon_rekognition_celebrity_detection">Amazon Rekognition Celebrity Detection</a> add-on.</p>
<table style="width:94%;margin-left:3%; margin-right:3%;">
<tr>
<td style="background-color:#D5D8DC; padding: 10px;">
Customers are increasingly looking for innovative ways to generate more data around their media assets to derive actionable business insights. By using Amazon Rekognition, Cloudinary is bringing this technology closer to its clients so they can build their own unique experience.

<p style="text-align:right;"><i>- Ranju Das, Director of Amazon Rekognition, Amazon Web Services, Inc. </i></p>
</td>
</tr>
</table>
<a class="anchor" name="amazon_rekognition_categorization"></a><h2><a href="#amazon_rekognition_categorization">Amazon Rekognition: Categorization</a></h2><p>The Amazon Rekognition Auto Tagging add-on can automatically identify what&#39;s in a photograph and returns a list of detected categories and the confidence score of each category. The add-on is very simple to use: just set the <code>categorization</code> parameter of Cloudinary&#39;s image upload API to <code>aws_rek_tagging</code> while uploading a new image or updating an existing image and the response will include a list of identified tags for the image.</p><p>For example, uploading the following picture of a puppy to Cloudinary and requesting categorization:</p><div class="example multi_code "><a class="anchor" name="api_example_1"></a><div class="code_sample framework_sample active" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">Cloudinary</span>::<span style="color:#036;font-weight:bold">Uploader</span>.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:categorization</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>\<span style="color:#036;font-weight:bold">Uploader</span>::upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">categorization</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>,
  categorization = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.v2.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>, 
  {<span style="color:#606">categorization</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>},
  <span style="color:#080;font-weight:bold">function</span>(error, result){console.log(result);});</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader().upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>, ObjectUtils.asMap(
  <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">categorization</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div></div><p><div class="example multi_code "><a class="anchor" name="image_of_a_cute_puppy"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/cute_puppy.jpg" data-popup="true"><span class="prefix">https://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans"></span><span class="public_id">cute_puppy.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>).image()</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">'</span></span>).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cute_puppy.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/cute_puppy.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:1280px;"><div class="content-img-inner-wrapper" style="padding-top: 71.41%;"><img alt="image of a cute puppy" src="https://res.cloudinary.com/demo/image/upload/cute_puppy.jpg" style="margin: 0 auto;display: block" title="image of a cute puppy" /></div></div></a></p><p>The upload response includes the various categories that were automatically detected in the uploaded photo together with the confidence level of the detected category. So Amazon Rekognition is 91% sure that the picture contains a puppy and is 82% sure that the breed is Newfoundland.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
<span style="color:#606"><span style="color:#404">&quot;</span><span>info</span><span style="color:#404">&quot;</span></span>: {
  <span style="color:#606"><span style="color:#404">&quot;</span><span>categorization</span><span style="color:#404">&quot;</span></span>: {
    <span style="color:#606"><span style="color:#404">&quot;</span><span>aws_rek_tagging</span><span style="color:#404">&quot;</span></span>: {
      <span style="color:#606"><span style="color:#404">&quot;</span><span>status</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">complete</span><span style="color:#710">&quot;</span></span>, 
      <span style="color:#606"><span style="color:#404">&quot;</span><span>data</span><span style="color:#404">&quot;</span></span>: [
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Animal</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>},
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Canine</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Dog</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Mammal</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Pet</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Puppy</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9117</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Newfoundland</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.8253</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Husky</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.596</span>}, 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Adorable</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.5791</span>} 
<span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span></pre></div>
</div>
</div></div><p>For more information on the Amazon Rekognition Auto Tagging add-on, see the <a href="/documentation/aws_rekognition_auto_tagging_addon">documentation</a>.</p><a class="anchor" name="amazon_rekognition_celebrity_detection"></a><h2><a href="#amazon_rekognition_celebrity_detection">Amazon Rekognition: Celebrity Detection</a></h2><p>The Amazon Rekognition Celebrity Detection add-on can automatically recognize thousands of celebrities in a wide range of categories, such as entertainment and media, sports, business, and politics. 
This add-on is also very simple to use: just set the <code>detection</code> parameter of Cloudinary&#39;s image upload API to <code>aws_rek_face</code> while uploading a new image or updating an existing image, and the response will include a list of identified celebrities for the image. </p><p>For example, uploading the following picture to Cloudinary and requesting detection:</p><div class="example multi_code "><a class="anchor" name="api_example_3"></a><div class="code_sample framework_sample active" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">Cloudinary</span>::<span style="color:#036;font-weight:bold">Uploader</span>.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:detection</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>\<span style="color:#036;font-weight:bold">Uploader</span>::upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">detection</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>,
  detection = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.v2.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>, 
  {<span style="color:#606">detection</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>},
  <span style="color:#080;font-weight:bold">function</span>(error, result){console.log(result);});</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader().upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>, ObjectUtils.asMap(
  <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">detection</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div></div><p><div class="example multi_code "><a class="anchor" name="brangelina"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/brangelina.jpg" data-popup="true"><span class="prefix">https://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans"></span><span class="public_id">brangelina.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>).image()</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">'</span></span>).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">brangelina.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/brangelina.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:640px;"><div class="content-img-inner-wrapper" style="padding-top: 78.59%;"><img alt="brangelina" src="https://res.cloudinary.com/demo/image/upload/brangelina.jpg" style="margin: 0 auto;display: block" title="brangelina" /></div></div></a></p><p>The upload response includes the various celebrities that were automatically detected in the uploaded photo together with the confidence level of the detected celebrity. So Amazon Rekognition is 100% sure that this is a picture of Brad Pitt and Angelina Jolie. The response also includes information about unrecognized faces detected in the image if relevant, and the results provide detailed data on each face&#39;s location, pose, orientation within the image, and facial landmarks. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>{
...
<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">info</span><span style="color:#710">&quot;</span></span>: 
  {<span style="color:#606"><span style="color:#404">&quot;</span><span>detection</span><span style="color:#404">&quot;</span></span>: 
    {<span style="color:#606"><span style="color:#404">&quot;</span><span>aws_rek_face</span><span style="color:#404">&quot;</span></span>: 
      {<span style="color:#606"><span style="color:#404">&quot;</span><span>status</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">complete</span><span style="color:#710">&quot;</span></span>,
       <span style="color:#606"><span style="color:#404">&quot;</span><span>data</span><span style="color:#404">&quot;</span></span>: 
        {<span style="color:#606"><span style="color:#404">&quot;</span><span>celebrity_faces</span><span style="color:#404">&quot;</span></span>: 
          [{ 
            <span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Angelina Jolie</span><span style="color:#710">&quot;</span></span>,
            <span style="color:#606"><span style="color:#404">&quot;</span><span>match_confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">100.0</span>
            <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">face</span><span style="color:#710">&quot;</span></span>:
             {<span style="color:#606"><span style="color:#404">&quot;</span><span>bounding_box</span><span style="color:#404">&quot;</span></span>:
               {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span>...
              },
              <span style="color:#606"><span style="color:#404">&quot;</span><span>landmarks</span><span style="color:#404">&quot;</span></span>:
               [{<span style="color:#606"><span style="color:#404">&quot;</span><span>type</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">eyeLeft</span><span style="color:#710">&quot;</span></span>,
                 <span style="color:#606"><span style="color:#404">&quot;</span><span>x</span><span style="color:#404">&quot;</span></span>: ...
               }],
            ...
           },
                 ...
            <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">name</span><span style="color:#710">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Brad Pitt</span><span style="color:#710">&quot;</span></span>,
            <span style="color:#606"><span style="color:#404">&quot;</span><span>match_confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">100.0</span>},
                 ...
        <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">unrecognized_faces</span><span style="color:#710">&quot;</span></span>: [ ],
         ...
}}}}}</pre></div>
</div>
</div></div><p>For more information on the Amazon Rekognition Celebrity Detection add-on, see the <a href="/documentation/aws_rekognition_celebrity_and_face_detection_addon">documentation</a>.</p><a class="anchor" name="automatically_tagging_images"></a><h2><a href="#automatically_tagging_images">Automatically tagging images</a></h2><p>Cloudinary allows you to <a href="/documentation/upload_images#tagging_images">tag uploaded images</a>, where each image can be assigned one or more tags. You can also leverage the Amazon Rekognition add-ons to automatically assign tags to your images based on a minimum confidence score of identified categories/celebrities.</p><p>Simply add the <code>auto_tagging</code> parameter to the upload call and the image is automatically assigned resource tags based on the Amazon Rekognition detected categories/celebrities. The value of the <code>auto_tagging</code> parameter is the minimum confidence score of a detected celebrity that should be used for the automatically assigned resource tag. The value of the <code>auto_tagging</code> parameter is given as a decimal value between 0 and 1, where 1 represents 100%. Assigning these resource tags allows you to list and search images in your media library using Cloudinary&#39;s API and Web interface.</p><p>Note that the automatic tagging feature can be used with either of the Amazon Rekognition add-ons or with <strong>both</strong> together. The following example automatically tags an uploaded image with all detected categories <em>and</em> celebrities that have a confidence score of at least 70% (auto_tagging = 0.7).</p><div class="example multi_code "><a class="anchor" name="api_example_5"></a><div class="code_sample framework_sample active" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">Cloudinary</span>::<span style="color:#036;font-weight:bold">Uploader</span>.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:detection</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:categorization</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>,
  <span style="color:#A60">:auto_tagging</span> =&gt; <span style="color:#60E">0.7</span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>\<span style="color:#036;font-weight:bold">Uploader</span>::upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#369;font-weight:bold">array</span>(
    <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">detection</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>, 
    <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">categorization</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>, 
    <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto_tagging</span><span style="color:#710">&quot;</span></span> =&gt; <span style="color:#60E">0.7</span>));</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>,
  detection = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>,
  categorization = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>,
  auto_tagging = <span style="color:#60E">0.7</span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.v2.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>, {
  <span style="color:#606">detection</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#606">categorization</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#606">auto_tagging</span>: <span style="color:#60E">0.7</span>},
  <span style="color:#080;font-weight:bold">function</span>(error, result){console.log(result);});</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader().upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>, ObjectUtils.asMap(
  <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">detection</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_face</span><span style="color:#710">&quot;</span></span>, 
  <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">categorization</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek_tagging</span><span style="color:#710">&quot;</span></span>,
  <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">auto_tagging</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">0.7</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div></div><p><div class="example multi_code "><a class="anchor" name="steve_jobs"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><div class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/steve.jpg" data-popup="true"><span class="prefix">https://res.cloudinary.com/demo/</span><span class="kind">image/upload/</span><span class="signature"></span><span class="trans"></span><span class="public_id">steve.jpg</span></a></span></div></div></div><div class="code_sample framework_sample" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl_image_tag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>CloudinaryImage(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>).image()</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.url().imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="js"><div class="framework_name">JS:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cl.imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">steve.jpg</span><span style="color:#710">'</span></span>).toHtml();</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="jquery"><div class="framework_name">jQuery:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#369;font-weight:bold">$</span>.cloudinary.image(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="react"><div class="framework_name">React:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">publicId</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/Image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="angular"><div class="framework_name">Angular:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-image</span> <span style="color:#b48">public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#070;font-weight:bold">&gt;</span>

<span style="color:#070;font-weight:bold">&lt;/cl-image&gt;</span></pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="csharp"><div class="framework_name">.Net:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.Api.UrlImgUp.BuildImageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="android"><div class="framework_name">Android:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>MediaManager.get().url().generate(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">steve.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/steve.jpg" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:3259px;"><div class="content-img-inner-wrapper" style="padding-top: 98.01%;"><img alt="Steve Jobs" src="https://res.cloudinary.com/demo/image/upload/steve.jpg" style="margin: 0 auto;display: block" title="Steve Jobs" /></div></div></a></p><p>The response of the upload API call above returns the <strong>detected categories</strong>, the <strong>detected celebrities</strong>, and the <strong>automatically assigned tags</strong>.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>{
   <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
  <span style="color:#606"><span style="color:#404">&quot;</span><span>tags</span><span style="color:#404">&quot;</span></span>: [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">people</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">person</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">human</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">electronics</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">iphone</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">mobile phone</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">phone</span><span style="color:#710">&quot;</span></span>,<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Steve Jobs</span><span style="color:#710">&quot;</span></span>]
  <span style="color:#606"><span style="color:#404">&quot;</span><span>info</span><span style="color:#404">&quot;</span></span>: {
    <span style="color:#606"><span style="color:#404">&quot;</span><span>detection</span><span style="color:#404">&quot;</span></span>: {
      <span style="color:#606"><span style="color:#404">&quot;</span><span>aws_rek_face</span><span style="color:#404">&quot;</span></span>: {
        <span style="color:#606"><span style="color:#404">&quot;</span><span>status</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">complete</span><span style="color:#710">&quot;</span></span>,
        <span style="color:#606"><span style="color:#404">&quot;</span><span>data</span><span style="color:#404">&quot;</span></span>: [{
           <span style="color:#606"><span style="color:#404">&quot;</span><span>name</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Steve Jobs</span><span style="color:#710">&quot;</span></span>, 
           <span style="color:#606"><span style="color:#404">&quot;</span><span>match_confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">99.99</span>,
            <span style="color:#606"><span style="color:#404">&quot;</span><span>face</span><span style="color:#404">&quot;</span></span>: {
              <span style="color:#606"><span style="color:#404">&quot;</span><span>bounding_box</span><span style="color:#404">&quot;</span></span>: {
                <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">width</span><span style="color:#710">&quot;</span></span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
             },
             <span style="color:#606"><span style="color:#404">&quot;</span><span>landmarks</span><span style="color:#404">&quot;</span></span>: [{
               <span style="color:#606"><span style="color:#404">&quot;</span><span>type</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">eyeLeft</span><span style="color:#710">&quot;</span></span>,
                 <span style="color:#606"><span style="color:#404">&quot;</span><span>x</span><span style="color:#404">&quot;</span></span>: <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
               }],
            <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
           },
        <span style="color:#606"><span style="color:#404">&quot;</span><span>unrecognized_faces</span><span style="color:#404">&quot;</span></span>: [ ],
         <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>
     }
     <span style="color:#606"><span style="color:#404">&quot;</span><span>categorization</span><span style="color:#404">&quot;</span></span>: {
       <span style="color:#606"><span style="color:#404">&quot;</span><span>aws_rek_tagging</span><span style="color:#404">&quot;</span></span>: {
         <span style="color:#606"><span style="color:#404">&quot;</span><span>status</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">complete</span><span style="color:#710">&quot;</span></span>, 
         <span style="color:#606"><span style="color:#404">&quot;</span><span>data</span><span style="color:#404">&quot;</span></span>: [{
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">People</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9925</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Person</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9925</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Human</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.9924</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Electronics</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.7918</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Iphone</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.7918</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Mobile Phone</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.7918</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Phone</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.7918</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Computer</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.6756</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Tablet Computer</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.6756</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.5396</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Selfie</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.5396</span>},
           <span style="color:#606"><span style="color:#404">&quot;</span><span>tag</span><span style="color:#404">&quot;</span></span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Cell Phone</span><span style="color:#710">&quot;</span></span>, <span style="color:#606"><span style="color:#404">&quot;</span><span>confidence</span><span style="color:#404">&quot;</span></span>: <span style="color:#60E">0.5067</span>}]}
      <span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span><span style="color:#F00;background-color:#FAA">.</span>  
}</pre></div>
</div>
</div></div><a class="anchor" name="summary"></a><h2><a href="#summary">Summary</a></h2><p>Understanding the images that your users upload can provide you with great insights, allow you to take actions such as creating dynamic content pages, and match content to user preferences. Cloudinary’s service together with the fully integrated <a href="/documentation/aws_rekognition_auto_tagging_addon">Amazon Rekognition Auto Tagging</a> and <a href="/documentation/aws_rekognition_celebrity_and_face_detection_addon">Amazon Rekognition Celebrity Detection</a> add-ons provides developers with the powerful ability to enhance their image content management as well as increase their online users’ engagement and conversion.</p><p><a href="https://cloudinary.com/console/addons?#aws_rek_face" target="_blank"><img src=https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/aws_rek_celebrity_detection.jpg></img></a></p><p><a href="https://cloudinary.com/console/addons?#aws_rek_tagging" target="_blank"><img src=https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/aws_rek_auto_tagging.jpg ></img></a></p><p>The add-ons are available with all Cloudinary plans, and both add-ons have a free tier for you to try out. If you don&#39;t have a Cloudinary account yet, sign up for a free account <a href="https://cloudinary.com/users/register/free" data-popup="true">here</a>.</p><p><small>(Hugh Laurie photo credit to <a href="https://www.flickr.com/photos/elfidomx/" data-popup="true">Fido</a>)</small></p>]]>
      </description>
      <author />
      <pubDate>Thu, 19 Oct 2017 18:38:56 +0000</pubDate>
      <link>https://cloudinary.com/blog/how_to_automatically_tag_images_with_amazon_rekognition</link>
      <guid>https://cloudinary.com/blog/how_to_automatically_tag_images_with_amazon_rekognition</guid>
    </item>
    <item>
      <title>How to Automate Image Moderation with Amazon Rekognition</title>
      <description>
        <![CDATA[<p><a href="https://res.cloudinary.com/demo/image/upload/Rekognition_moderation_blog.png" data-popup="true"><div class="content-img-outer-wrapper" style="max-width:1920px;"><div class="content-img-inner-wrapper" style="padding-top: 56.25%;"><img alt="Moderation with Rekognition" src="https://res.cloudinary.com/demo/image/upload/Rekognition_moderation_blog.png" style="margin: 0 auto;display: block" title="Moderation with Rekognition" /></div></div></a></p><p>Allowing your users to upload their own images to your website can increase user engagement, retention and monetization. However, allowing your users to upload any image they want to, may lead to some of your users uploading inappropriate images to your application. These images may offend other users or even cause your site to violate standards or regulations.</p><p>If you have any ads appearing on your site, you also need to protect your advertiser&#39;s brands by ensuring that they don&#39;t appear alongside any adult content. Some advertising networks are very intolerant and blacklist any website that displays adult content, even if that content was submitted by users. </p><p>Cloudinary&#39;s image management solution already provides a manual moderation web interface and API to help do this efficiently. However, manual moderation is time consuming and is not instantaneous, and so we wanted to provide an additional option - automatic moderation of images as your users upload them.</p><a class="anchor" name="introducing_the_amazon_rekognition_ai_moderation_add_on"></a><h2><a href="#introducing_the_amazon_rekognition_ai_moderation_add_on">Introducing the Amazon Rekognition AI Moderation add-on</a></h2><p>Cloudinary provides an add-on for <a href="https://aws.amazon.com/rekognition/" data-popup="true">Amazon Rekognition&#39;s</a> image moderation service based on deep learning algorithms, fully integrated into Cloudinary&#39;s image management and manipulation pipeline. With Amazon Rekognition&#39;s AI Moderation add-on, you can extend Cloudinary&#39;s powerful cloud-based image media library and delivery capabilities with automatic, artificial intelligence-based moderation of your photos. Protect your users from explicit and suggestive adult content in your user-uploaded images, making sure that no offensive photos are displayed to your web and mobile viewers.  </p><p><div class="content-img-outer-wrapper" style="max-width:1170px;"><div class="content-img-inner-wrapper" style="padding-top: 44.1%;"><img alt="Moderation with Rekognition" src="https://cloudinary-res.cloudinary.com/image/upload/amazon_aws_chart.jpg" style="margin: 0 auto;display: block" title="Moderation with Rekognition" /></div></div></p><a class="anchor" name="enabling_automatic_image_moderation_by_amazon_rekognition"></a><h2><a href="#enabling_automatic_image_moderation_by_amazon_rekognition">Enabling automatic image moderation by Amazon Rekognition</a></h2><p>To request moderation while uploading an image, simply set the <code>moderation</code> upload API parameter to <code>aws_rek</code>:</p><div class="example multi_code "><a class="anchor" name="api_example_1"></a><div class="code_sample framework_sample active" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">Cloudinary</span>::<span style="color:#036;font-weight:bold">Uploader</span>.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sample_image.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:moderation</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>\<span style="color:#036;font-weight:bold">Uploader</span>::upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sample_image.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">moderation</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sample_image.jpg</span><span style="color:#710">&quot;</span></span>,
  moderation = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.v2.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sample_image.jpg</span><span style="color:#710">&quot;</span></span>, 
  {<span style="color:#606">moderation</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek</span><span style="color:#710">&quot;</span></span>},
  <span style="color:#080;font-weight:bold">function</span>(error, result){console.log(result);});</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader().upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sample_image.jpg</span><span style="color:#710">&quot;</span></span>, 
  ObjectUtils.asMap(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">moderation</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div></div><p>The uploaded image is automatically sent to Amazon Rekognition for moderation: Amazon Rekognition assigns a moderation confidence score (0 - 100) indicating the chances that an image belongs to an offensive content category. The default moderation confidence level is 0.5 unless specifically overridden (see below), and all images classified by Amazon Rekognition with a value greater than the moderation confidence level are classified as &#39;rejected&#39;. Otherwise, their status is set to &#39;approved&#39;, with all results included in the upload response. </p><p>This means that your user can be instantaneously alerted to the fact if their image was rejected, improving the end user experience (no waiting for approval or suddenly finding their image gone at a later date due to manual moderation). A rejected image is moved to a secondary backup repository, and is not automatically delivered. If you choose, you can manually review rejected images and mark them as approved if appropriate as described later in this article.</p><a class="anchor" name="fine_tuning_the_image_moderation"></a><h2><a href="#fine_tuning_the_image_moderation">Fine-tuning the image moderation</a></h2><p>The automatic moderation can be configured for different content categories, allowing you to fine-tune what kinds of images you deem acceptable or objectionable. By default, any image that Amazon Rekognition determines to be adult content with a confidence score of over 50% is automatically rejected. This minimum confidence score can be overridden for any of the categories with a new default value (see the <a href="/documentation/aws_rekognition_ai_moderation#moderation_categorization">documentation</a> for a breakdown of the available categories). For example, to request moderation for the <code>supermodel</code> image, with the moderation confidence level set to 0.75 for the &#39;Female Swimwear or Underwear&#39; sub-category, 0.6 for the &#39;Explicit Nudity&#39; top-level category (overriding the default for all its child categories as well) and exclude the &#39;Revealing Clothes&#39; category:</p><div class="example multi_code "><a class="anchor" name="api_example_2"></a><div class="code_sample framework_sample active" data-framework="ruby"><div class="framework_name">Ruby:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">Cloudinary</span>::<span style="color:#036;font-weight:bold">Uploader</span>.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">supermodel.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#A60">:moderation</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek:female_underwear:0.75:explicit_nudity:0.6:revealing_clothes:ignore</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="php"><div class="framework_name">PHP:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>\<span style="color:#036;font-weight:bold">Uploader</span>::upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">supermodel.jpg</span><span style="color:#710">&quot;</span></span>, 
  <span style="color:#369;font-weight:bold">array</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">moderation</span><span style="color:#710">&quot;</span></span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek:female_underwear:0.75:explicit_nudity:0.6:revealing_clothes:ignore</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="python"><div class="framework_name">Python:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">supermodel.jpg</span><span style="color:#710">&quot;</span></span>,
  moderation = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek:female_underwear:0.75:explicit_nudity:0.6:revealing_clothes:ignore</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="nodejs"><div class="framework_name">Node.js:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.v2.uploader.upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">supermodel.jpg</span><span style="color:#710">&quot;</span></span>, 
  {<span style="color:#606">moderation</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek:female_underwear:0.75:explicit_nudity:0.6:revealing_clothes:ignore</span><span style="color:#710">&quot;</span></span>},
  <span style="color:#080;font-weight:bold">function</span>(error, result){console.log(result);});</pre></div>
</div>
</div></div></div><div class="code_sample framework_sample" data-framework="java"><div class="framework_name">Java:</div><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cloudinary.uploader().upload(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">supermodel.jpg</span><span style="color:#710">&quot;</span></span>, 
  ObjectUtils.asMap(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">moderation</span><span style="color:#710">&quot;</span></span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">aws_rek:female_underwear:0.75:explicit_nudity:0.6:revealing_clothes:ignore</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div></div></div><a class="anchor" name="manage_moderated_images"></a><h2><a href="#manage_moderated_images">Manage moderated images</a></h2><p>No matter how powerful and reliable an artificial intelligence algorithm is, it can never be 100% accurate, and in some cases of moderation, &quot;accuracy&quot; might be suggestive. Furthermore, you may configure your moderation tool to err on the conservative side, which may result in an occasional rejected image that may have been OK. </p><p>While the automated moderation minimizes efforts and provides instantaneous results, you may sometimes want to adjust the moderation status of a specific image manually.</p><p>You can also use the API or web interface to alter the automatic moderation decision. You can browse rejected or approved images, and then manually approve or reject them as needed. If you choose to approve a previously rejected image, the original version of the rejected image will be restored from backup, and if you choose to reject a previously approved image, cache invalidation will be performed for the image so it will be erased from all the CDN cache servers.</p><p>For more information, see the detailed <a href="/documentation/aws_rekognition_ai_moderation_addon">documentation</a>.</p><a class="anchor" name="moderation_made_easy"></a><h2><a href="#moderation_made_easy">Moderation made easy</a></h2><p>Moderating your user-generated images is important to protect your brand and keep your users and advertisers happy. With the <a href="/documentation/aws_rekognition_ai_moderation_addon">Amazon Rekognition AI Moderation</a> add-on, you can provide feedback within the upload stream and fine-tune the filters that you use to determine what kinds of images you deem acceptable or objectionable. Automated moderation can help you to improve photo sharing sites, forums, dating apps, content platforms for children, e-commerce platforms and marketplaces, and more.</p><p><a href="https://cloudinary.com/console/addons?#aws_rek_moderation" target="_blank"><img src=https://res.cloudinary.com/demo/image/upload/f_auto,q_auto/aws_rek_ai_moderation.png></img></a></p><p>The add-on is available with all Cloudinary plans, with a free tier for you to try it out. If you don&#39;t have a Cloudinary account yet, sign up for a free account <a href="https://cloudinary.com/users/register/free" data-popup="true">here</a>.</p>]]>
      </description>
      <author />
      <pubDate>Wed, 18 Oct 2017 17:39:22 +0000</pubDate>
      <link>https://cloudinary.com/blog/how_to_automate_image_moderation_with_amazon_rekognition</link>
      <guid>https://cloudinary.com/blog/how_to_automate_image_moderation_with_amazon_rekognition</guid>
    </item>
  </channel>
</rss>
