<?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>http://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>The power of ImageMagick with the speed and simplicity of Cloudinary</title>
      <description>
        <![CDATA[<p><img alt="The power of ImageMagick with the speed and simplicity of Cloudinary" height="1100" src="http://cloudinary-res.cloudinary.com/image/upload/v1487750849/cloudinary_imagemagick" style="margin: 0 auto;display: block" title="The power of ImageMagick with the speed and simplicity of Cloudinary" width="2000" /></p><p>Most developers are familiar with <a href="https://www.imagemagick.org/script/index.php" data-popup="true" rel="nofollow">ImageMagick</a>, a very capable open source software suite that they can use to manage and manipulate images. </p><p>The functionality of ImageMagick is typically utilized from the command-line, but wrappers have been written for a wide selection of programming languages, making ImageMagick a very popular choice among developers.</p><p>Often programmers use ImageMagick for simple operations such as scaling or stretching an image to fit specific dimensions.
But as we&#39;ll see in this post, there are many advanced techniques available, such as &#39;masking’, pixel &#39;blending&#39; and others that enable you to achieve more complex and extremely useful effects.</p><p>In this post, I’ll share three examples of image manipulations using <a href="https://github.com/rmagick/rmagick" data-popup="true" rel="nofollow">RMagick</a> (a Ruby wrapper for ImageMagick). I will start with a sepia effect combined with an overlay image, and follow that with increasingly complex manipulations such as creating text textures and pixelating faces.  For each of these examples, I’ll compare what it takes to address the same challenges using Cloudinary.  With its cloud-based platform, Cloudinary eliminates the complexity of coding and the hassles associated with installation. Cloudinary also saves developers time, enabling them to leverage a single line of code to complete the image manipulations. </p><a class="anchor" name="dependencies_and_installation"></a><h3><a href="#dependencies_and_installation">Dependencies and Installation</a></h3><p>You can find the full source code for this blog post in <a href="https://github.com/Cloudinary/imagemagick_blog" data-popup="true" rel="nofollow">Cloudinary’s official repository in Github</a>.
Installing the dependencies for the examples is not a trivial task, mostly because of OpenCV. But for simplicity’s sake, I’ve containerized both ImageMagick and OpenCV dependencies, so you only need to have <a href="https://www.docker.com/" data-popup="true" rel="nofollow">Docker</a> installed.</p><a class="anchor" name="example_1_sepia_effect_with_text_overlay"></a><h2><a href="#example_1_sepia_effect_with_text_overlay">Example 1: Sepia effect with text overlay</a></h2><p>The first example describes a common use case: Adding a photographer&#39;s name to the bottom right corner of an image.<br>
To make the example more interesting, we first want to apply a sepia effect.<br>
The final result should look something like this:</p><p><a href="https://res.cloudinary.com/demo/image/upload/sepia_and_overlay.png" data-popup="true"><img alt="Sepia and Overlay" height="333" src="https://res.cloudinary.com/demo/image/upload/sepia_and_overlay.png" style="margin: 0 auto;display: block" title="Sepia and Overlay" width="500" /></a></p><a class="anchor" name="the_imagemagick_way"></a><h3><a href="#the_imagemagick_way">The ImageMagick way:</a></h3><p>The example is built using two main methods:  </p>
<ul>
<li><strong><code>add_author_to_image!</code></strong>, which receives a <code>Magick::Image</code> object and the <code>author</code> name and returns a new <code>Magick::Image</code> object that contains the resulting image - the original image with the author name overlay applied.</li>
<li><strong><code>sepiatize_image!</code></strong>, which receives a <code>Magick::Image</code> object and returns the modified image object with the sepia effect applied.</li>
</ul>
<p>First, let’s describe <strong><code>add_author_to_image!</code></strong>:<br>
Using ImageMagick, I create a <code>Draw</code> object, which will enable me to put the text over the original image.<br>
I also select the color “white”, “Arial” as the font, and choose my font size.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>text = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Draw</span>.new
text.fill = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</span><span style="color:#710">&quot;</span></span>
text.font_family = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Arial</span><span style="color:#710">&quot;</span></span>
text.pointsize = <span style="color:#00D">30</span>
text.gravity = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">CenterGravity</span></pre></div>
</div>
</div></div><p>The overlay image size should match the text dimensions, so I need to calculate the text dimensions before creating the overlay image:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>metrics = text.get_type_metrics(author)</pre></div>
</div>
</div></div><p>I then create the overlay image and set its background color to a semi-transparent black to ensure that the text will be visible on top of any image. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>author_overlay = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Image</span>.new(metrics.width, metrics.height) {
  <span style="color:#069">self</span>.background_color = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#00000080</span><span style="color:#710">&quot;</span></span>
}</pre></div>
</div>
</div></div><p>Next, I draw the text over the the semi-transparent background.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>text.annotate(author_overlay, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, author)</pre></div>
</div>
</div></div><p>Then I position the author overlay on top of the image:</p><p>I use the <code>composite</code> method to combine the two images in a certain way.  The destination image is our input image.  I have to tell ImageMagick that I want to position the author overlay in the “southeast” edge of the image.
<code>Magick::OverCompositeOp</code> tells ImageMagick that the source image (<code>author_overlay</code>) should override the destination image (our input image) with the source image’s pixels, which makes the author name visible on top of the image. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>image.composite!(author_overlay, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">SouthEastGravity</span>, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">OverCompositeOp</span>)</pre></div>
</div>
</div></div><p>The final step is destroying the author image object overlay. It’s important to clean up any temporary image objects. I don’t need the overlay anymore because I’ve combined the images and flattened them. Destroying an image object is done using the <code>destroy!</code> method:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>author_overlay.destroy!</pre></div>
</div>
</div></div><p>What’s missing now is the sepia effect (applied by the <code>sepiatize_image!</code> method).<br>
ImageMagick offers a method for setting sepia tone, so I chose the sepia level and set the desired effect. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">SEPIA_LEVEL</span> = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">QuantumRange</span> * <span style="color:#00D">60</span> / <span style="color:#00D">100</span>
<span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">sepiatize_image!</span>(image)
  image.sepiatone(<span style="color:#036;font-weight:bold">SEPIA_LEVEL</span>)
<span style="color:#080;font-weight:bold">end</span></pre></div>
</div>
</div></div><p>After defining the two methods, we need to apply both operations on our original image and write the result to a file:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>add_author_to_image!(sepiatize_image!(source_image), author).write(dest)</pre></div>
</div>
</div></div><p>Whew! I’m sweating a bit, but I managed to get the result I wanted.</p><a class="anchor" name="the_cloudinary_way"></a><h3><a href="#the_cloudinary_way">The Cloudinary way:</a></h3><p>If this is your first time using Cloudinary, you’ll need <a href="https://cloudinary.com/users/register/free" data-popup="true">sign up for an account</a> (start with a free one), and use the upload API to upload your image. You can use the https API with no installation required, or <a href="http://cloudinary.com/documentation" data-popup="true">download and install the SDK</a> for your favorite framework (a few quick configurations required).</p><p>Here’s how you would upload the yellow_tulip.png file to your account in the cloud using the Ruby SDK:`</p><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">'</span><span style="color:#D20">yellow_tulip.png</span><span style="color:#710">'</span></span>, <span style="color:#A60">:public_id</span> =&gt; <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">yellow_tulip</span><span style="color:#710">'</span></span>)</pre></div>
</div>
</div></div><p>Now, let’s see what it takes to deliver that image in sepia with the photographer’s name in the corner. Ready?</p><p><div class="example multi_code "><a class="anchor" name="sepia_and_overlay"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/e_sepia:60/l_text:Arial_30:John%20Doe%20Photography%20%C2%AE,co_white,g_south_east,b_rgb:00000090/yellow_tulip.png" 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">e_sepia:60/l_text:Arial_30:John Doe Photography ®,co_white,g_south_east,b_rgb:00000090/</span><span class="public_id">yellow_tulip.png</span></a></span></code></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">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:secure</span>=&gt;<span style="color:#069">true</span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:color</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</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">south_east</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">#00000090</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">yellow_tulip.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">secure</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#069">true</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">effect</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">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</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">color</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">white</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">south_east</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>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#00000090</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">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>).image(secure=<span style="color:#069">True</span>, transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</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">color</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">white</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">south_east</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">#00000090</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">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</span>, <span style="color:#606">transformation</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">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</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">south_east</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">#00000090</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()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</span><span style="color:#710">&quot;</span></span>).color(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</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">south_east</span><span style="color:#710">&quot;</span></span>).background(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#00000090</span><span style="color:#710">&quot;</span></span>)).secure(<span style="color:#069">true</span>).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>)</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">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</span>, <span style="color:#606">transformation</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">sepia:60</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">text:Arial_30:John%20Doe%20Photography%20%C2%AE</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</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">south_east</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">#00000090</span><span style="color:#710">&quot;</span></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(new Transformation()
  .Effect(&quot;sepia:60&quot;).Chain()
  .Overlay(&quot;text:Arial_30:John%20Doe%20Photography%20%C2%AE&quot;).Color(&quot;white&quot;).Gravity(&quot;south_east&quot;).Background(&quot;#00000090&quot;)).Secure(true).BuildImageTag(&quot;yellow_tulip.png&quot;)</pre></div>
</div>
</div></div></div></div></p><p>Done!</p><a class="anchor" name="example_2_text_textures"></a><h2><a href="#example_2_text_textures">Example 2: Text Textures</a></h2><p>In this example, which is a bit more complex than our first one, I will use our source image as a texture effect on specified text with a selected font, so that it will look something like this:  </p><p><a href="https://res.cloudinary.com/demo/image/upload/text_textures.png" data-popup="true"><img alt="Text Textures" height="73" src="https://res.cloudinary.com/demo/image/upload/text_textures.png" style="margin: 0 auto;display: block" title="Text Textures" width="367" /></a></p><a class="anchor" name="the_imagemagick_way"></a><h3><a href="#the_imagemagick_way">The ImageMagick way:</a></h3><p>I will employ the concept of <a href="https://www.tutorialspoint.com/dip/concept_of_masks.htm" data-popup="true" rel="nofollow">masking</a> in this example.<br>
Let&#39;s create a &#39;mask&#39; image in the shape of our desired text and font. I do this using the <code>create_text_mask</code> method, which receives the text as a string and returns a &#39;mask&#39; <code>Image</code> object.<br>
The following is a short walkthrough:</p><p>Like in the previous example, I create a <code>Draw</code> object, which is being used for the text.<br>
I then add color, font family, size and weight, and get a type metric to create our ‘mask’ image object with the dimensions I calculated.</p><p>Then I create a new <code>Image</code> object and set it&#39;s background to transparent:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>draw = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Draw</span>.new
draw.fill = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</span><span style="color:#710">&quot;</span></span>
draw.font_family = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Arial</span><span style="color:#710">&quot;</span></span>
draw.pointsize = <span style="color:#00D">100</span>
draw.font_weight = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">BoldWeight</span>
draw.gravity = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">CenterGravity</span>
metrics = draw.get_type_metrics(text)
mask = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Image</span>.new(metrics.width, metrics.height) { <span style="color:#069">self</span>.background_color = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">transparent</span><span style="color:#710">&quot;</span></span> }</pre></div>
</div>
</div></div><p>Like in the previous example, I use the draw object’s annotate method to actually draw the text over the image I’ve created.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>draw.annotate(mask, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, <span style="color:#00D">0</span>, text)</pre></div>
</div>
</div></div><p>The result is a semi transparent image having the text itself in fully opaque &quot;white&quot; and the rest - fully transparent.</p><p>Let&#39;s move to the <code>cut_image_to_text!</code> method which calls <code>create_text_mask</code>:<br>
After creating the mask image by calling <code>create_text_mask</code>, using the <code>composite</code> method, I combine the &#39;mask&#39; image and our input image, but this time relying on a different type of composite operator: <code>CopyOpacityCompositeOp</code>.<br>
Doing this changes the opacity value of all pixels in our input image that are not part of the text letters region, to fully transparent. This hides the pixels and results in a texture effect over the fonts:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>image.composite!(mask, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">CenterGravity</span>, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">CopyOpacityCompositeOp</span>)</pre></div>
</div>
</div></div><p>Next, I have to clean up by destroying the <code>mask</code> image, which isn&#39;t needed anymore.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>mask.destroy!</pre></div>
</div>
</div></div><p>Then I trim the remaining transparent border and tighten up the image to the text itself.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>image.trim!</pre></div>
</div>
</div></div><p>At this point I’m almost done, but there’s one last thing to take care of.<br>
A lot of formats – like JPEG – don’t have an alpha channel to support opacity.  So, if you export the image now in one of those non-alpha formats, you’ll see the original image since all &#39;hidden&#39; and &#39;fully transparent&#39; pixels from our last step will not preserve their transparency.  As a result, I’ll need to turn all transparent pixels to “opaque white”, which will make sure I get a uniform result no matter what the desired format is. This will be done using the simple <code>opacify!</code> method.</p><p>Here I set the background color to white:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>opacified = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Image</span>.new(image.columns, image.rows) { <span style="color:#069">self</span>.background_color = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">white</span><span style="color:#710">&quot;</span></span> }</pre></div>
</div>
</div></div><p>Then I put the cut-to-text image that I created in the previous step on top of the new image with the white background color. This causes all transparent pixels from before to turn white.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>opacified.composite!(image, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">CenterGravity</span>, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">OverCompositeOp</span>)</pre></div>
</div>
</div></div><p>After defining the relevant methods,  I apply them on the original image and write the result to a file:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>opacify!(cut_image_to_text!(source, text)).write(dest)</pre></div>
</div>
</div></div><p>Impressive! We did it!</p><a class="anchor" name="the_cloudinary_way"></a><h3><a href="#the_cloudinary_way">The Cloudinary way:</a></h3><p>You’d think this example would take a bit more effort than the previous one, even in Cloudinary. But with a combination of text overlay capabilities and the built-in <code>cutter</code> flag, here’s all we need to do:</p><p><div class="example multi_code "><a class="anchor" name="text_textures"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/l_text:Arial_100_bold:Flowers,fl_cutter/yellow_tulip.png" 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">l_text:Arial_100_bold:Flowers,fl_cutter/</span><span class="public_id">yellow_tulip.png</span></a></span></code></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">yellow_tulip.png</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">text:Arial_100_bold:Flowers</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">cutter</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:secure</span>=&gt;<span style="color:#069">true</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">yellow_tulip.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">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">text:Arial_100_bold:Flowers</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>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cutter</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">secure</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#069">true</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">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>).image(overlay=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">text:Arial_100_bold:Flowers</span><span style="color:#710">&quot;</span></span>, flags=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cutter</span><span style="color:#710">&quot;</span></span>, secure=<span style="color:#069">True</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">yellow_tulip.png</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">text:Arial_100_bold:Flowers</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">cutter</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">secure</span>: <span style="color:#069">true</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().overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">text:Arial_100_bold:Flowers</span><span style="color:#710">&quot;</span></span>).flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cutter</span><span style="color:#710">&quot;</span></span>)).secure(<span style="color:#069">true</span>).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">yellow_tulip.png</span><span style="color:#710">&quot;</span></span>)</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">yellow_tulip.png</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">text:Arial_100_bold:Flowers</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">cutter</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">secure</span>: <span style="color:#069">true</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(new Transformation().Overlay(&quot;text:Arial_100_bold:Flowers&quot;).Flags(&quot;cutter&quot;)).Secure(true).BuildImageTag(&quot;yellow_tulip.png&quot;)</pre></div>
</div>
</div></div></div></div></p><a class="anchor" name="example_3_pixelating_faces"></a><h2><a href="#example_3_pixelating_faces">Example 3: Pixelating Faces</a></h2><p>For my last example, I will show how to combine face detection with a pixelation effect, which is really useful for hiding people’s identities in public photos. Here’s what our final image will look like:</p><p> <a href="https://res.cloudinary.com/demo/image/upload/pixelate_faces.jpg" data-popup="true"><img alt="Pixelating Faces" height="332" src="https://res.cloudinary.com/demo/image/upload/pixelate_faces.jpg" style="margin: 0 auto;display: block" title="Pixelating Faces" width="500" /></a></p><a class="anchor" name="the_imagemagick_way"></a><h3><a href="#the_imagemagick_way">The ImageMagick way:</a></h3><p>This example involves use of the <a href="http://opencv.org/" data-popup="true" rel="nofollow">OpenCV</a> library and the <a href="https://github.com/ruby-opencv/ruby-opencv" data-popup="true" rel="nofollow">ruby-opencv</a> gem. My code in this example is written in a flexible way that enables  easy swapping of the face detection part to any other library or implementation (modify the <code>detect_faces</code> method to one of your liking, but you must make sure it returns an array of regions).</p><p>First, let’s have a look at the <code>transform_faces</code> method.<br>
I’m creating a <code>Magick:Image</code> object out of this file, which I took from the user’s input, similar to the way I’ve done in our first two examples.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>image = <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">Image</span>.read(image_file).first</pre></div>
</div>
</div></div><p>Then I detect faces for the image file. This process, which is done outside of ImageMagick, returns a collection of face regions.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>detect_faces(image_file).each <span style="color:#080;font-weight:bold">do</span> |region|
  transform_region!(image, region, operation)
<span style="color:#080;font-weight:bold">end</span></pre></div>
</div>
</div></div><p>Next, for each region, I call <code>transform_region!</code> over the image object. The <code>transform_region</code> method has <code>top_left</code> and <code>bottom_right</code> attributes, each with an <code>X</code>,<code>Y</code> value.  Here I crop a new image out of the original image at the exact region that was identified.  </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cropped_region = image.crop(region.top_left.x, region.top_left.y, region.width, region.height)</pre></div>
</div>
</div></div><p>Then I call a method for the operation that I want to do with this cropped region image.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>cropped_region = send(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="background-color:hsla(0,0%,0%,0.07);color:black"><span style="font-weight:bold;color:#666">#{</span>operation<span style="font-weight:bold;color:#666">}</span></span><span style="color:#D20">_image!</span><span style="color:#710">&quot;</span></span>, cropped_region)</pre></div>
</div>
</div></div><p>In the example code in the repository, I pick an operation called <code>pixelate</code>.  However, you also could select “blur” if that treatment was preferred:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#036;font-weight:bold">PIXELATE_FACTOR</span> = <span style="color:#00D">5</span>
<span style="color:#080;font-weight:bold">def</span> <span style="color:#06B;font-weight:bold">pixelate_image!</span>(image)
  image.scale!(<span style="color:#00D">1</span> / <span style="color:#036;font-weight:bold">PIXELATE_FACTOR</span>.to_f).scale!(<span style="color:#036;font-weight:bold">PIXELATE_FACTOR</span>)
<span style="color:#080;font-weight:bold">end</span></pre></div>
</div>
</div></div><p>Back to <code>transform_region!</code>: I need to set the &quot;transformed&quot; region on top of the original image, using <code>composite</code> again at the <code>X</code>,<code>Y</code> position. After that is complete, I flatten the image and then clean it up by destroying the cropped image region. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>image.composite!(cropped_region, region.top_left.x, region.top_left.y, <span style="color:#036;font-weight:bold">Magick</span>::<span style="color:#036;font-weight:bold">OverCompositeOp</span>)
cropped_region.destroy!</pre></div>
</div>
</div></div><p>Not bad, huh?</p><a class="anchor" name="the_cloudinary_way"></a><h3><a href="#the_cloudinary_way">The Cloudinary way:</a></h3><p>By now, you have probably come to expect that you can accomplish the same goal with Cloudinary in one line of code, right? Yup!</p><p>Cloudinary has a built-in automatic face detection mechanism that enables, among other things, quick pixelation (or blurring) of all faces in a photo:</p><p><strong>Pixelating faces</strong>
 <div class="example multi_code "><a class="anchor" name="pixelating_faces"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/fetch/e_pixelate_faces/w_500/http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg" data-popup="true"><span class="prefix">https://res.cloudinary.com/demo/</span><span class="kind">image/fetch/</span><span class="signature"></span><span class="trans">e_pixelate_faces/w_500/</span><span class="public_id">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span></a></span></code></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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:secure</span>=&gt;<span style="color:#069">true</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>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:width</span>=&gt;<span style="color:#00D">500</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>}
  ])</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.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">secure</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#069">true</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>, <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">effect</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">pixelate_faces</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">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">500</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>)
  )))</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>).image(secure=<span style="color:#069">True</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>, transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">pixelate_faces</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">500</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>}
  ])</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</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>, <span style="color:#606">transformation</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">pixelate_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">500</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>}
  ]})</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()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate_faces</span><span style="color:#710">&quot;</span></span>).chain()
  .width(<span style="color:#00D">500</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>)).secure(<span style="color:#069">true</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>)</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</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>, <span style="color:#606">transformation</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">pixelate_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">500</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>}
  ]})</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(new Transformation()
  .Effect(&quot;pixelate_faces&quot;).Chain()
  .Width(500).Crop(&quot;scale&quot;)).Secure(true).Type(&quot;fetch&quot;).BuildImageTag(&quot;http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg&quot;)</pre></div>
</div>
</div></div></div></div></p><p><strong>Blurring faces</strong>
<div class="example multi_code "><a class="anchor" name="blurring_faces"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/fetch/e_blur_faces/w_500/http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg" data-popup="true"><span class="prefix">https://res.cloudinary.com/demo/</span><span class="kind">image/fetch/</span><span class="signature"></span><span class="trans">e_blur_faces/w_500/</span><span class="public_id">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span></a></span></code></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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:secure</span>=&gt;<span style="color:#069">true</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>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">blur_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:width</span>=&gt;<span style="color:#00D">500</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>}
  ])</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.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">secure</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#069">true</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>, <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">effect</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">blur_faces</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">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">500</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>)
  )))</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>).image(secure=<span style="color:#069">True</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>, transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">blur_faces</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">500</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>}
  ])</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</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>, <span style="color:#606">transformation</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">blur_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">500</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>}
  ]})</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()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">blur_faces</span><span style="color:#710">&quot;</span></span>).chain()
  .width(<span style="color:#00D">500</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>)).secure(<span style="color:#069">true</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>)</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">http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</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>, <span style="color:#606">transformation</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">blur_faces</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">500</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>}
  ]})</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(new Transformation()
  .Effect(&quot;blur_faces&quot;).Chain()
  .Width(500).Crop(&quot;scale&quot;)).Secure(true).Type(&quot;fetch&quot;).BuildImageTag(&quot;http://upload.wikimedia.org/wikipedia/commons/4/45/Spain_national_football_team_Euro_2012_final.jpg&quot;)</pre></div>
</div>
</div></div></div></div></p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>ImageMagick is a flexible, capable, open source software suite that developers have used to manage and manipulate images for years. As we saw in this post, ImageMagick can be utilized to do so much more than simply resizing an image.  </p><p>At Cloudinary, we make use of ImageMagick for a wide range of use cases, and it serves as one of the valuable tools in our toolbelt.</p><p>Cloudinary abstracts the complexities of image manipulation, storage,  administration and delivery and provides developers with an easy-to-use, end-to-end, cloud-based solution. Cloudinary enables developers to focus on creating their apps and presenting the best images possible. </p><p>If you haven&#39;t tried Cloudinary yet, I invite you to test it out. Visit our website to <a href="https://cloudinary.com/users/register/free" data-popup="true">sign up for a account</a></p>]]>
      </description>
      <author />
      <pubDate>Thu, 23 Feb 2017 15:55:40 +0000</pubDate>
      <link>http://cloudinary.com/blog/the_power_of_imagemagick_with_the_speed_and_simplicity_of_cloudinary</link>
      <guid>http://cloudinary.com/blog/the_power_of_imagemagick_with_the_speed_and_simplicity_of_cloudinary</guid>
    </item>
    <item>
      <title>4 Image Management Best Practices</title>
      <description>
        <![CDATA[<div> <img src="http://res.cloudinary.com/demo/image/upload/v1487707644/Best_practices_urnvuq.jpg" alt="Best_Practices" width="770" height="513">
</div>
<div>There’s no debating the fact that including images on your website or mobile app draws the interest of users and leads to stronger engagement. For example, posts that include images produce 650 percent higher engagement than text-only posts, according to a <a href="https://webdam.com/blog/brand-marketing-infographic" target="_blank">WebDAM infographic</a>. Use of attention-grabbing images is only going to grow. Consider that by 2018, 84 percent of communication will be visual, the infographic noted. </div>
<div> </div>
<div>But delivering a consistent experience – and the optimal image – across a variety of desktop and mobile devices still remains a huge challenge for developers. They need to consider the size of images – since larger files take longer to download, eat up bandwidth and have a negative impact on website performance and user experience – as well as the type of device on which its being viewed and the graphic design in which the image is placed.  </div>
<div> </div>
<div>Efficient image management is the key when you want to improve engagement with visually appealing images, offer faster loading pages with appropriate image formats, and deliver a consistent experience across a wide range of devices that require different graphic layouts, resolutions and viewports. The goals: to improve development productivity, speed your website to market, and find a way to avoid creating multiple versions of each image to support responsive design. </div>
<div> </div>
<div>To help you meet these goals, there are four best practices you should employ:</div>
<div><span style="font-size: x-large;"> </span></div>
<div><span style="font-size: large;"><strong><span style="font-size: x-large;">1. Optimize Images for Better Performance</span> </strong></span></div>
<div><span style="font-size: large;"><strong><br></strong></span></div>
<div>Image optimization involves delivering images with the smallest possible file size while maintaining visual quality. Doing this will save bytes and speed the performance of your website. </div>
<div> </div>
<div>To select the optimal image, you must understand all the various factors that influence the image's file size and quality, as well as consider what actions may result in unnecessary bandwidth use, such as wasteful browser-side resizing, delivering static icons one by one and using a single image size across all delivery mediums.  </div>
<div> </div>
<div>One of the major aspects of image optimization involves selecting the correct format to deliver to your users, and avoiding use of unnecessarily high image quality images. You should look for a solution that dynamically selects the most efficient format – either traditional JPEG, PNG and GIF, or modern formats, such as WebP developed by Google and JPEG-XR developed by Microsoft – and automatically adjusts the compression quality appropriately for every scenario. </div>
<div> </div>
<div>With growing use of responsive design, you’ll need to make sure that you also are able to scale and crop images to fit any page layout, on any device.</div>
<div> </div>
<div>In this <a href="http://cloudinary.com/blog/introducing_smart_cropping_intelligent_quality_selection_and_automated_responsive_images" target="_blank">blog</a>, you can learn more about how Cloudinary supports content- and context-aware cropping, dynamic format selection and automated creation of responsive images, all from a single image.</div>
<div><span style="font-size: x-large;"> </span></div>
<div><span style="font-size: x-large;"><strong>2. Simplify Workflow</strong></span></div>
<div><span style="font-size: x-large;"><strong><br></strong></span></div>
<div>There’s no doubt you have a specific workflow associated with adding images to your site or app.  In many cases, a designer will create artwork, then the developer requests multiple sizes for display on various devices and multiple formats for different browsers. Then they have to store multiple versions and write the logic that enables the right version to be selected and delivered to every user. If you’ve ever done this, you know it takes a significant amount of time, and can slow your time to market. </div>
<div> </div>
<div>Ideally, you should automate the process as much as possible. Any solution you use should enable you to create one high-quality version of an image, which can then be dynamically transformed and delivered in the proper version to suit the viewing requirements of every user and every device. By doing so, you will save time and resources by not requiring your designer to designer to create multiple versions of every image, or do additional work if you need the images transformed in any way. </div>
<div> </div>
<div><span style="font-size: x-large;"><strong>3. Move to HTTP/2</strong></span></div>
<div><span style="font-size: x-large;"><strong><br></strong></span></div>
<div>Even though websites have changed dramatically in looks and style over the years – from simple text-based pages to advanced in-browser apps full of images and videos – the underlying HTTP protocol really hasn’t changed - until recently, with the approval of the HTTP/2 protocol by the IETF. Use of <a href="http://cloudinary.com/blog/cloudinary_adds_support_for_http_2" target="_blank">HTTP/2</a> can help you optimize the user experience on your app or website even more.</div>
<div> </div>
<div>Generally this new HTTP protocol will improve  website performance; reduce the amount of bandwidth required by supporting header compression; improve latency and make it easier for developers to use optimized connections, by eliminating the need for domain sharding and other subtle performance tricks.</div>
<div> </div>
<div>The biggest difference you’ll see when moving to HTTP/2 is with image-heavy pages. And the more images on a single page, the more improvement that will be seen. The reason: With HTTP/2, instead of requesting images sequentially or creating many parallel connections, the browser makes a single connection to the server and optimizes the requests to all images over a single connection. </div>
<div> </div>
<div><span style="font-size: x-large;"><strong>4. Leverage CDNs for Globally Distributed Caching</strong></span></div>
<div><span style="font-size: x-large;"><strong><br></strong></span></div>
<div>Content distribution networks (CDNs) are large, geographically distributed network of specialized servers that accelerate the delivery of web content and rich media to internet-connected devices.  </div>
<div> </div>
<div>CDNs provide many benefits to various parties, including web users, content and application owners and service providers. These networks support faster page loads, improving the user experience, which ultimately lowers abandonment rates, increases impression, improves conversion rates and strengthens customer loyalty. </div>
<div> </div>
<div>These best practices will enable you to create a seamless, end-to-end process for dealing with images, including uploading, organizing, viewing, storing, delivering and managing all of the images. With the Cloudinary solution, you can do all of this quickly and effectively from a single platform, which will further help reduce the integration hassle and chaos, while improving team collaboration. </div>
<div> </div>
<div>To see for yourself how Cloudinary can help your company establish best practices, sign up today for <a href="https://cloudinary.com/users/register/free" target="_blank">FREE</a>. </div>
<div> </div>]]>
      </description>
      <author />
      <pubDate>Tue, 21 Feb 2017 20:40:05 +0000</pubDate>
      <link>http://cloudinary.com/blog/4_image_management_best_practices</link>
      <guid>http://cloudinary.com/blog/4_image_management_best_practices</guid>
    </item>
    <item>
      <title>File Upload With PHP</title>
      <description>
        <![CDATA[<p><img alt="PHP" height="467" src="http://cloudinary-res.cloudinary.com/image/upload/w_700/php_upload_cover_blog.jpg" style="margin: 0 auto;display: block" title="PHP" width="700" /></p><p>There are lots of images and videos all over the internet. A lot of applications these days demand that the user is able to manipulate files and upload to the server. Thankfully, PHP provides the functions to handle file uploads.</p><p>In this post, I’ll show you two ways of handling file uploads with PHP: </p>
<ul>
<li><a href="#php_upload_the_barebones_way" rel="nofollow">The Barebones PHP way</a></li>
<li><a href="#handling_file_upload_with_cloudinary" rel="nofollow">Using Cloudinary’s Cloud Service</a> - Cloudinary is an end-to-end solution for all your image and video-related needs. It allows you to securely upload images or any other file at any scale from any source. Cloudinary also provides an API for fast upload directly from your users’ browsers or mobile apps. Check out <a href="http://cloudinary.com/documentation/solution_overview" data-popup="true">Cloudinary’s documentation</a> for more information on how to integrate it in your apps.</li>
</ul>
<a class="anchor" name="php_upload_the_barebones_way"></a><h2><a href="#php_upload_the_barebones_way">PHP upload - The barebones way</a></h2><p>Let’s quickly get started on how to handle file upload with PHP, the barebones way. We need:</p><a class="anchor" name="1_the_html_form"></a><h3><a href="#1_the_html_form">1. The HTML Form</a></h3><p>You need to build up an HTML form that will contain the fields that the user will interact with to upload a file. Create an <code>index.html</code> file in your root directory and add the following code to it:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#34b">&lt;!DOCTYPE html&gt;</span>
<span style="color:#070;font-weight:bold">&lt;html</span> <span style="color:#b48">lang</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">en</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;head&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;meta</span> <span style="color:#b48">charset</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">UTF-8</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;title&gt;</span>File Upload with PHP<span style="color:#070;font-weight:bold">&lt;/title&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/head&gt;</span>
<span style="color:#070;font-weight:bold">&lt;body&gt;</span>
    <span style="color:#070;font-weight:bold">&lt;form</span> <span style="color:#b48">action</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">fileUpload.php</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">method</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">post</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">enctype</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">multipart/form-data</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
        Upload a File:
        <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">file</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">name</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">file</span><span style="color:#710">&quot;</span></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">fileToUpload</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">submit</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">name</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">submit</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">value</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Upload File Now</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;/form&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/body&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/html&gt;</span></pre></div>
</div>
</div></div><p>In the code above, we have a form with one <strong>input field</strong> and a <strong>submit button</strong>.  The <strong>form</strong> tag has an <strong>action</strong> attribute that points to the script that will take care of the actual upload process. It also has a <strong>method</strong> attribute that specifies the kind of operation this form will undertake, which is a <strong>POST</strong> action.</p><p>The value of the <strong>enctype</strong> attribute is very important. It determines the content-type that the form submits. If we were not dealing with file uploads, then we would not specify the <strong>enctype</strong> attribute on the form in most cases.</p><p>Spin up your PHP server like so:
 <a href="http://res.cloudinary.com/demo/image/upload/php_server_up.png" data-popup="true"><img alt="spin up the PHP server" height="97" src="http://res.cloudinary.com/demo/image/upload/w_700/php_server_up.png" style="margin: 0 auto;display: block" title="spin up the PHP server" width="700" /></a></p><p>You should see something similar to this come up on your web page:</p><p> <a href="http://res.cloudinary.com/demo/image/upload/php_upload_webpage.png" data-popup="true"><img alt="Web page with upload options" height="291" src="http://res.cloudinary.com/demo/image/upload/w_540/php_upload_webpage.png" style="margin: 0 auto;display: block" title="Web page with upload options" width="540" /></a></p><p><strong>Note</strong>: Different browsers, such as Safari, Edge, Firefox and Chrome might display the form in different ways.</p><a class="anchor" name="2_php_upload_script"></a><h3><a href="#2_php_upload_script">2. PHP Upload Script</a></h3><p>There are lots of things to consider when dealing with file uploads. I’ll highlight the common ones in form of questions.</p>
<ul>
<li>In which directory will the files be stored?</li>
<li>Is the directory writable?</li>
<li>What type of files should the users be allowed to upload?</li>
<li>What is the maximum file size that the server should allow?</li>
<li>Should the user be allowed to upload the same image more than once?</li>
</ul>
<p>Create a file, <strong>fileUpload.php</strong>,  in the root directory and add this code to it:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>
<span style="font-weight:bold;color:#666">&lt;?php</span>
    <span style="color:#950">$currentDir</span> = <span style="color:#369;font-weight:bold">getcwd</span>();
    <span style="color:#950">$uploadDirectory</span> = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">/uploads/</span><span style="color:#710">&quot;</span></span>;

    <span style="color:#950">$errors</span> = []; <span style="color:#777">// Store all foreseen and unforseen errors here</span>

    <span style="color:#950">$fileExtensions</span> = [<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">jpeg</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">jpg</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">png</span><span style="color:#710">'</span></span>]; <span style="color:#777">// Get all the file extensions</span>

    <span style="color:#950">$fileName</span> = <span style="color:#369;font-weight:bold">$_FILES</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">myfile</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">name</span><span style="color:#710">'</span></span>];
    <span style="color:#950">$fileSize</span> = <span style="color:#369;font-weight:bold">$_FILES</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">myfile</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">size</span><span style="color:#710">'</span></span>];
    <span style="color:#950">$fileTmpName</span>  = <span style="color:#369;font-weight:bold">$_FILES</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">myfile</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">tmp_name</span><span style="color:#710">'</span></span>];
    <span style="color:#950">$fileType</span> = <span style="color:#369;font-weight:bold">$_FILES</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">myfile</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">type</span><span style="color:#710">'</span></span>];
    <span style="color:#950">$fileExtension</span> = <span style="color:#369;font-weight:bold">strtolower</span>(<span style="color:#369;font-weight:bold">end</span>(<span style="color:#369;font-weight:bold">explode</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">.</span><span style="color:#710">'</span></span>,<span style="color:#950">$fileName</span>)));

    <span style="color:#950">$uploadPath</span> = <span style="color:#950">$currentDir</span> . <span style="color:#950">$uploadDirectory</span> . <span style="color:#369;font-weight:bold">basename</span>(<span style="color:#950">$fileName</span>); 

    <span style="color:#080;font-weight:bold">if</span> (<span style="color:#369;font-weight:bold">isset</span>(<span style="color:#369;font-weight:bold">$_POST</span>[<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">submit</span><span style="color:#710">'</span></span>])) {

        <span style="color:#080;font-weight:bold">if</span> (! <span style="color:#369;font-weight:bold">in_array</span>(<span style="color:#950">$fileExtension</span>,<span style="color:#950">$fileExtensions</span>)) {
            <span style="color:#950">$errors</span>[] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">This file extension is not allowed. Please upload a JPEG or PNG file</span><span style="color:#710">&quot;</span></span>;
        }

        <span style="color:#080;font-weight:bold">if</span> (<span style="color:#950">$fileSize</span> &gt; <span style="color:#00D">2000000</span>) {
            <span style="color:#950">$errors</span>[] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">This file is more than 2MB. Sorry, it has to be less than or equal to 2MB</span><span style="color:#710">&quot;</span></span>;
        }

        <span style="color:#080;font-weight:bold">if</span> (<span style="color:#369;font-weight:bold">empty</span>(<span style="color:#950">$errors</span>)) {
            <span style="color:#950">$didUpload</span> = move_uploaded_file(<span style="color:#950">$fileTmpName</span>, <span style="color:#950">$uploadPath</span>);

            <span style="color:#080;font-weight:bold">if</span> (<span style="color:#950">$didUpload</span>) {
                <span style="color:#369;font-weight:bold">echo</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">The file </span><span style="color:#710">&quot;</span></span> . <span style="color:#369;font-weight:bold">basename</span>(<span style="color:#950">$fileName</span>) . <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20"> has been uploaded</span><span style="color:#710">&quot;</span></span>;
            } <span style="color:#080;font-weight:bold">else</span> {
                <span style="color:#369;font-weight:bold">echo</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">An error occurred somewhere. Try again or contact the admin</span><span style="color:#710">&quot;</span></span>;
            }
        } <span style="color:#080;font-weight:bold">else</span> {
            <span style="color:#080;font-weight:bold">foreach</span> (<span style="color:#950">$errors</span> <span style="color:#080;font-weight:bold">as</span> <span style="color:#950">$error</span>) {
                <span style="color:#369;font-weight:bold">echo</span> <span style="color:#950">$error</span> . <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">These are the errors</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:#b0b">\n</span><span style="color:#710">&quot;</span></span>;
            }
        }
    }


<span style="font-weight:bold;color:#666">?&gt;</span></pre></div>
</div>
</div></div><p>Look at the code above.</p>
<ul>
<li><strong>$fileName = $_FILES[&#39;myfile&#39;][&#39;name&#39;];</strong>  This refers to the real name of the uploaded file.</li>
<li><strong>$fileSize = $_FILES[&#39;myfile&#39;][&#39;size&#39;];</strong> This refers to the size of the file.</li>
<li><strong>$fileTmpName  = $_FILES[&#39;myfile&#39;][&#39;tmp_name&#39;];</strong> This is the temporary uploaded file that resides in the <strong>tmp/</strong> directory of the web server.</li>
<li><strong>$fileType = $_FILES[&#39;myfile&#39;][&#39;type&#39;];</strong> This refers to the type of the file. Is it a jpeg or png or mp3 file?</li>
<li><strong>$fileExtension = strtolower(end(explode(&#39;.&#39;,$fileName)));</strong> This grabs the extension of the file. </li>
<li><strong>$uploadPath = $currentDir . $uploadDirectory . basename($fileName);</strong>  This is the path where the files will be stored on the server. We grabbed the current working directory.</li>
</ul>
<p>In the code, we are checking to ensure that only <strong>jpeg</strong> and <strong>png</strong> files can be uploaded. </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">if</span> (! <span style="color:#369;font-weight:bold">in_array</span>(<span style="color:#950">$fileExtension</span>,<span style="color:#950">$fileExtensions</span>)) {
            <span style="color:#950">$errors</span>[] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">This file extension is not allowed. Please upload a JPEG or PNG file</span><span style="color:#710">&quot;</span></span>;
        }
<span style="color:#777">// Checks to ensure that only jpeg and png files can be uploaded.</span></pre></div>
</div>
</div></div><p>We are also checking that only files less than or equal to 2MB can be uploaded.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#080;font-weight:bold">if</span> (<span style="color:#950">$fileSize</span> &gt; <span style="color:#00D">2000000</span>) {
            <span style="color:#950">$errors</span>[] = <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">This file is larger than 2MB. It must be less than or equal to 2MB</span><span style="color:#710">&quot;</span></span>;
        }
<span style="color:#777">// Checks to ensure the file is not more than 2MB</span></pre></div>
</div>
</div></div><p><strong>Note</strong>: Before you try out your code again, you need to ensure that there are some configurations in place.</p>
<ul>
<li>Make sure the <code>uploads/</code> directory is writable. Run this command: <code>chmod 0755 uploads/</code> on your terminal to make the directory writable.</li>
<li><p>Open your <code>php.ini</code> file and ensure that these constants have correct values like:</p>
<ul>
<li><strong>max_file_uploads</strong> = 20</li>
<li><strong>upload_max_size</strong> = 2M</li>
<li><strong>post_max_size</strong> = 8M</li>
</ul></li>
</ul>
<p>Now, run the code again. Your file should upload successfully to the <strong>uploads</strong> directory.</p><p><strong>Note</strong>: There are many checks you should consider when handling file uploads, including security precautions . You really don’t want someone uploading a virus to your web server. Do you? So by all means don’t use this exact code above in production. Add more valuable checks!</p><p>Also, it’s recommended that you upload your files to a dedicated file server, not just your web application server. Check out the <a href="https://github.com/unicodeveloper/cld-php-file-upload-proc" data-popup="true" rel="nofollow">source code</a> for a tutorial.</p><a class="anchor" name="handling_file_upload_with_cloudinary"></a><h2><a href="#handling_file_upload_with_cloudinary">Handling File Upload With Cloudinary</a></h2><p>Cloudinary provides an API for uploading images and any other kind of file to the cloud. These files are safely stored in the cloud with secure backups and revision history.</p><p>Cloudinary provides a free tier where you can store up to 75,000 images &amp; videos with a managed storage of 2GB. 7500 monthly transformations and 5GB monthly net viewing bandwidth.</p><p>Cloudinary already takes away the pain of having to write large amounts of code to interact with their API by providing an <a href="https://github.com/cloudinary/cloudinary_php" data-popup="true" rel="nofollow">open source PHP library</a> that ships with simple, easy-to-use helper methods for:</p>
<ol>
<li>Image uploading</li>
<li>Image administration and sprite generation</li>
<li>Embedding images</li>
<li>Building URLs for image transformation and manipulation</li>
</ol>
<p>The process is this simple!</p><a class="anchor" name="1_a_href_https_cloudinary_com_users_register_free_data_popup_true_sign_up_for_a_cloudinary_account_a"></a><h3><a href="#1_a_href_https_cloudinary_com_users_register_free_data_popup_true_sign_up_for_a_cloudinary_account_a">1. <a href="https://cloudinary.com/users/register/free" data-popup="true">Sign up for a Cloudinary Account</a></a></h3><p> <img alt="Web page with upload options" height="474" src="http://res-3.cloudinary.com/cloudinary/image/upload/dpr_auto/w_700/console_dashboard.jpg" style="margin: 0 auto;display: block" title="Web page with upload options" width="700" />
<small><i><strong>Cloudinary Dashboard</strong> - Your <strong>cloud name</strong>, <strong>API Key</strong>, <strong>Secret</strong> are key valuables to interact with Cloudinary functionalities.</i></small></p><a class="anchor" name="2_fetch_the_cloudinary_php_library"></a><h3><a href="#2_fetch_the_cloudinary_php_library">2. Fetch the Cloudinary PHP library</a></h3><p> <a href="http://res.cloudinary.com/demo/image/upload/php_fetch_library.png" data-popup="true"><img alt="fetch the PHP SDK library" height="150" src="http://res.cloudinary.com/demo/image/upload/w_540/php_fetch_library.png" style="margin: 0 auto;display: block" title="fetch the PHP SDK library" width="540" /></a>
The second step to uploading your images to Cloudinary using PHP is fetching the library using composer. 
If you don’t have composer, navigate <a href="https://github.com/cloudinary/cloudinary_php/tree/master/src" data-popup="true" rel="nofollow">here</a>, make sure you copy all required files and paste them in your app, then reference them as follows in the script where you want to perform the upload:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>
<span style="color:#777">// importing the necessary Cloudinary files</span>
<span style="color:#369;font-weight:bold">require</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Cloudinary.php</span><span style="color:#710">'</span></span>;
<span style="color:#369;font-weight:bold">require</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Uploader.php</span><span style="color:#710">'</span></span>;
<span style="color:#369;font-weight:bold">require</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Helpers.php</span><span style="color:#710">'</span></span>;
<span style="color:#369;font-weight:bold">require</span> <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">Api.php</span><span style="color:#710">'</span></span>;
.....</pre></div>
</div>
</div></div><a class="anchor" name="3_server_side_upload"></a><h3><a href="#3_server_side_upload">3. Server-side upload</a></h3><p>You can upload images or any file to Cloudinary from your PHP code running on at least a <strong>PHP 5.3</strong> server. First, we have to set up our key valuables using the <strong>config</strong> method, so that Cloudinary can recognize that it’s a valid account:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>\<span style="color:#036;font-weight:bold">Cloudinary</span>::config(<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">cloud_name</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">my_cloud_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">api_key</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">my_api_key</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">api_secret</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">my_api_secret</span><span style="color:#710">&quot;</span></span>
));</pre></div>
</div>
</div></div><p><strong>Note</strong>: I recommend that you load these key valuables from an environment file (.env) to avoid people getting ahold of your config details.</p><p>You can put this in a file called <a href="https://github.com/cloudinary/cloudinary_php/blob/master/samples/basic/settings.php.sample" data-popup="true" rel="nofollow">settings.php</a> and just include it in the <a href="https://github.com/cloudinary/cloudinary_php/blob/master/samples/basic/basic.php" data-popup="true" rel="nofollow">script</a> that performs the actual uploading.</p><p>Now you can use the following methods to upload images or files to <strong>Cloudinary’s cloud</strong> platform:</p><p><strong>Uploading a local file</strong>:</p><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">/home/my_image.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div><p><strong>Uploading a file from a remote HTTP(s) URL:</strong></p><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">http://www.example.com/image.jpg</span><span style="color:#710">&quot;</span></span>)</pre></div>
</div>
</div></div><p><strong>Uploading a file from an S3 bucket:</strong></p><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">'</span><span style="color:#D20">s3://my-bucket/my-path/my-file.jpg</span><span style="color:#710">'</span></span>);</pre></div>
</div>
</div></div><p><strong>Note</strong>: Every file uploaded to Cloudinary is assigned a <strong>Public ID</strong> that can later be used for transformation and delivery.</p><p>The basic syntax for uploading your files with PHP to Cloudinary is:</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">static</span> <span style="color:#080;font-weight:bold">function</span> <span style="color:#06B;font-weight:bold">upload</span>(<span style="color:#950">$file</span>, <span style="color:#950">$options</span> = <span style="color:#369;font-weight:bold">array</span>())</pre></div>
</div>
</div></div><p>Let’s cover a few examples of what can be passed to the <strong>$options</strong> array argument.</p><p><strong>Specifying a custom Public ID:</strong></p><p>You want to specify a custom Public ID? Here, you go:</p><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">'</span><span style="color:#D20">my_image.jpg</span><span style="color:#710">'</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">public_id</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">manutd_id</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div><p><strong>Use the original name of the uploaded file:</strong></p><p>You want to preserve and use the original name of the uploaded file? Here, you go:</p><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">'</span><span style="color:#D20">sample.jpg</span><span style="color:#710">'</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">use_filename</span><span style="color:#710">&quot;</span></span> =&gt; <span style="color:#069">TRUE</span>));</pre></div>
</div>
</div></div><p>Upload an image, video, or a raw file:</p><p>Not sure whether a user will upload an image, video, or a raw file? Here, you go:</p><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">spreadsheet.xls</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">resource_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">auto</span><span style="color:#710">&quot;</span></span>));</pre></div>
</div>
</div></div><p>Note: See <a href="http://cloudinary.com/documentation/image_upload_api_reference#upload" data-popup="true">here</a> for all available upload options.</p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>We have successfully covered how to handle file uploads with PHP. Now, the hassle associated with file uploads should be a thing of the past. Storing your files on your host server also should be a thing of the past. Offload files to dedicated cloud storage services like Cloudinary and let them bear the headache of serving the files securely to your web app via CDN!</p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="http://res.cloudinary.com/cloudinary/image/upload/c_thumb,w_100/prosper_otemuyiwa.jpg" alt="Prosper Otemuyiwa" title="Prosper Otemuyiwa"></img></td>
<td style = "padding: 10px;"><i><a href="https://twitter.com/unicodeveloper" target="_new">Prosper Otemuyiwa</a> is a Food Ninja, Open Source Advocate & Self-acclaimed Developer Evangelist.</i></td>
</tr>
</table>
]]>
      </description>
      <author>Prosper Otemuyiwa</author>
      <pubDate>Wed, 15 Feb 2017 14:31:46 +0000</pubDate>
      <link>http://cloudinary.com/blog/file_upload_with_php</link>
      <guid>http://cloudinary.com/blog/file_upload_with_php</guid>
    </item>
    <item>
      <title>Responsive Images Guide, Part 2: Variable Image Resolution</title>
      <description>
        <![CDATA[<p><img alt="An image on a phone, tablet, and large desktop display" height="470" src="http://res.cloudinary.com/cloudinary/image/upload/w_700,f_auto,q_auto/respimg-guide/pt-2-hero.png" style="margin: 0 auto;display: block" title="An image on a phone, tablet, and large desktop display" width="700" /></p><p>In <a href="http://cloudinary.com/blog/responsive_images_guide_part_1_what_does_it_mean_for_an_image_to_be_responsive#fn-1-mark" data-popup="true">Part 1</a> of this series, I discussed (rather abstractly) what it means for an image to be “responsive.” In short, a responsive image is a <em>variable</em> image that adapts to fit variable contexts, in order to provide a great experience to users no matter what their screen, browser, network connection, or device may be.</p><p>That adaptive variability can take many forms; the most common and impactful of these is adaptive, variable, image <strong>resolution</strong>.</p><a class="anchor" name="fixed_vs_fluid"></a><h2><a href="#fixed_vs_fluid">Fixed vs Fluid</a></h2><p>Bitmap images have a <em>fixed</em> resolution: they contain a fixed number of pixels. <a href="https://alistapart.com/article/fluid-images" data-popup="true" rel="nofollow">Images on the web, however, are <em>fluid</em></a>, and the number of pixels that they occupy in layouts and on screens can <em>vary</em>.</p><p>Here’s an example. Let’s say we have an image—</p><p><img alt="image in a window, with resolution in the menubar" height="513" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/photo.png" style="margin: 0 auto;display: block" title="image in a window, with resolution in the menubar" width="700" /></p><p>—and we want to share it with the world. We put it on a website, and load that site on our phone:</p><p><img alt="Image on a website on a phone" height="700" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/on_phone.png" style="margin: 0 auto;display: block" title="Image on a website on a phone" width="700" /></p><p>It looks pretty sharp! Proud of our work, we send the URL to a friend, who just so happens to have a brand new 5K display:</p><p><img alt="Your images are blurry, brah" height="558" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/on_5k.png" style="margin: 0 auto;display: block" title="Your images are blurry, brah" width="700" /></p><p>He’s, well, less than impressed. The problem? Our original image has a resolution of 800 × 600 — so while it looks sharp-as-a-tack on our 750 × 1334 iPhone 7 screen, it looks horribly blurry when scaled to fit our friend’s 5120 × 2880 monster.</p><p>Crispness in this (extreme!) context requires a (much!) bigger image:</p>
<style>
.erics_table {
border-collapse: collapse;
margin: 2em auto;
}
.erics_table td:first-child,
.erics_table th {
padding: 0.25em 0.5em;
}
erics_table td {
padding: 0.5em;
}
.erics_table thead {
border-bottom: 1px solid #eee;
}
</style>

<table class="erics_table">
<thead><tr>
<th>resolution</th><th># of pixels</th><th># of bytes</th>
</tr></thead>
<tbody>
<tr>
<td>800 × 600</td><td style="text-align: right;">0.48 MP</td><td style="text-align: right;">66 kB</td>
</tr>
<tr>
<td>5000 × 3750</td><td style="text-align: right;">18.75 MP</td><td style="text-align: right;">2.2 MB</td>
</tr></tbody>
</table>
<p>To fill our friend’s 5K screen, our image would need almost <em>40 times more data</em>. This super-sized file would, all by itself, <a href="http://mobile.httparchive.org/interesting.php?a=All&amp;l=Dec%202%202016#bytesperpage" data-popup="true" rel="nofollow">outweigh the average webpage</a> and take forever to load over anything but the fastest internet connections. Worst of all, on smaller (and far more common) screens, our giant image would ultimately be downscaled to fit, and all of those extra pixels would be useless.</p><a class="anchor" name="multiple_alternate_versions"></a><h2><a href="#multiple_alternate_versions">Multiple, alternate versions</a></h2><p>So – should we use high-resolution images in order to take advantage of high-resolution hardware? Or should we use small images, which will load fast in low-resolution environments?</p><p>The answer, of course, is an emphatic “yes” to both, and everything in-between! We can and should include <em>multiple, alternate versions of our images</em> –</p><p><img alt="An array of progressively larger images" height="242" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/multiple_alternates.png" style="margin: 0 auto;display: block" title="An array of progressively larger images" width="700" /></p><p>— and make sure that we only send high-resolution versions to users who need them, while still sending low-resolution versions to everyone else.</p><p><img alt="Arrows pointing from those versions to a phone, tablet, and 5k display" height="642" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/multiple_alternates_delivered.png" style="margin: 0 auto;display: block" title="Arrows pointing from those versions to a phone, tablet, and 5k display" width="700" /></p><p>This concept is simple enough, and the the HTML feature that allows developers to supply those multiple alternates is straightforward, too; it’s called <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img#attr-srcset" data-popup="true" rel="nofollow"><code>srcset</code></a>.</p><p>But the devil is in the details, and figuring out—</p>
<ol>
<li>how many different versions you actually need</li>
<li>what their resolutions should be</li>
<li>and how to intelligently pick and load one of them from the set</li>
</ol>
<p>—is surprisingly tricky! We’ll tackle each of those problems in turn.</p><a class="anchor" name="how_many_versions_at_what_resolutions"></a><h2><a href="#how_many_versions_at_what_resolutions">How many versions, at what resolutions?</a></h2><p>In order to serve users in varying contexts well, we need to supply our image in multiple, alternate resolutions. But how many versions do we need, and what should their resolutions be?</p><p>This is a hard question, so let’s break it into smaller pieces. We can start by thinking about the limits: what are the largest and smallest resolutions that we’ll need? In order to figure <em>that</em> out, we need to consider: what are the largest and smallest sizes that our image can grow/shrink to on our layout? And what display sizes and densities do we actually care about supporting?</p><p>Once we’ve established the limits of our range, we need to figure out how to fill it in.</p><p><img alt="min, max, question marks around the in-between" height="372" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/min_max.png" style="margin: 0 auto;display: block" title="min, max, question marks around the in-between" width="700" /></p><p>For web devs, more resources means more to manage.</p><p>For users, more resources means less waste. But also, more HTML to download, and fewer cache hits, resulting in, paradoxically, slower loads.</p><p>How should we navigate these conflicting priorities? Initially, most developers threw up their hands and picked a more-or-less arbitrary step size, in pixels. <a href="https://cloudfour.com/thinks/responsive-images-101-part-9-image-breakpoints/" data-popup="true" rel="nofollow">Jason Grigsby pioneered the idea</a> that we can be smarter about this by using <em>file-size-based</em> steps, instead. So rather than having versions that were, say, 600, 800, and 1000 pixels-wide, we would generate versions that weighed 60 kB, 80 kB, and 100 kB.</p><p>Why? Because different images can have surprisingly different compression characteristics, and we care much more about the wasted <em>bytes</em> when we load an over-sized image, than we do wasted <em>pixels</em>.</p><p>Cloudinary thought that this file-size-based “responsive image breakpoint” strategy was pretty smart, and built the <a href="http://responsivebreakpoints.com" data-popup="true" rel="nofollow">Responsive Images Breakpoints Generator</a> in order to help developers implement it. The Generator allows you to input a high-res original image and pick a maximum resolution, minimum resolution, and step-size in kilobytes; it then generates a full set of alternate resources and provides a convenient download link along with the markup you need to include them all in your HTML. Neat!</p><a class="anchor" name="pickin_problems"></a><h2><a href="#pickin_problems">Pickin’ problems</a></h2><p>Now that we’ve marked up a set of multiple, alternate resources – how should browsers pick and load the most appropriate resource out of the set?</p><p>In order to choose, browsers need to know how many pixels are in this box:</p><p><img alt="Picture of an image on a website, highlighted" height="544" src="https://res.cloudinary.com/eric-cloudinary/image/upload/w_700,q_auto,f_auto/respimg-guide/how_big_is_this_box.png" style="margin: 0 auto;display: block" title="Picture of an image on a website, highlighted" width="700" /></p><p>Once they know that, they can pick the version that best fills the box. But! That box-size is determined by a number of things:</p>
<ol>
<li>the viewport size</li>
<li>the screen density</li>
<li>the page layout</li>
</ol>
<p>The viewport size and screen density are always known to the browser. Page layout, however, is where things get sticky.</p><p>When loading a webpage and parsing its HTML, browsers begin loading external resources (like CSS and images) as soon as they see their URLs in the markup. This is good for performance – <a href="http://mobile.httparchive.org/interesting.php#bytesperpage" data-popup="true" rel="nofollow">image bytes account for 68% of the web</a>, and we want to <a href="https://www.stevesouders.com/blog/2013/04/26/i/" data-popup="true" rel="nofollow">start moving those bytes across the network as soon as possible</a>. But it’s bad for layout-aware image loading, as it means that browsers don’t, won’t, and can’t wait for layout before kicking off image loads. The load-it-as-soon-as-you-see-it strategy means that we, as web developers, must choose between:</p>
<ul>
<li>intentionally delaying image loads and waiting for page layout to complete so that we know how many pixels of resolution we actually need, before loading a given image</li>
<li>kicking off image loads as soon as we possibly can (without knowing how many pixels we’ll actually need)</li>
</ul>
<p>In other words: do we want our images to be resolution-responsive, or loaded without delay? Because – without adding something else to this equation – we can’t have both.</p><a class="anchor" name="solutions"></a><h2><a href="#solutions">Solutions</a></h2><p>In some contexts, delayed, resolution-adaptive-sizing isn’t a problem. If an image is lazy-loaded (or even just below-the-fold), we can afford to wait for layout. The <a href="https://github.com/cloudinary/cloudinary_js" data-popup="true" rel="nofollow">Cloudinary Javascript library</a> and libraries like Alexander Farkas’ <a href="https://github.com/aFarkas/lazysizes" data-popup="true" rel="nofollow">lazy-sizes</a> circumvent the browser’s normal image loading mechanisms and responsively load images – after layout – with Javascript. </p><p>But if we want our resolution-responsive images <em>fast</em>, we need to short-circuit the normal flow of information. We need to <em>tell the browser the layout size of the image directly in markup</em>.</p><p>This is what <a href="https://cloudfour.com/thinks/responsive-images-101-part-5-sizes/" data-popup="true" rel="nofollow">the <code>sizes</code> attribute</a> is for. <code>sizes</code> declarations have a reputation for being difficult to read and I know from bitter experience that they can be tricky to write. Because the attribute was explicitly designed to break the <a href="https://en.wikipedia.org/wiki/Separation_of_presentation_and_content" data-popup="true" rel="nofollow">separation of concerns</a> and duplicate a little bit of layout information right there in markup, the most challenging thing about <code>sizes</code> might be maintenance; sites whose layout is subject to frequent tweaking will especially suffer.</p><p>The reason that <a href="https://ericportis.com/posts/2014/srcset-sizes#rainbow" data-popup="true" rel="nofollow">I love <code>sizes</code></a> <em>despite</em> its difficulties, is that it addresses the how-do-we-know-about-the-layout-before-we-know-about-the-layout problem <em>head on</em>, directly giving browsers the minimum amount of information that they need to start loading resolution-responsive images as soon as possible.</p><p>As such, <code>sizes</code> is <em>required</em> when using the <a href="https://cloudfour.com/thinks/responsive-images-101-part-4-srcset-width-descriptors/" data-popup="true" rel="nofollow"><code>srcset</code> attribute with <code>w</code> descriptors</a> – which is the standard (and <a href="https://caniuse.com/#feat=srcset" data-popup="true" rel="nofollow">universally supported</a>!) pattern for implementing resolution-adaptive responsive images.</p><a class="anchor" name="problematic_but_possible"></a><h2><a href="#problematic_but_possible">Problematic, but possible</a></h2><p>Fast, resolution-responsive images can be a bit tricky to implement, but the <a href="http://alistapart.com/article/responsive-images-in-practice#section3" data-popup="true" rel="nofollow">the payoff is enormous</a>. By supplying multiple versions of each image, and using either Javascript or <code>srcset</code> and <code>sizes</code> to pick amongst them, we can ensure that every user – whether they’re on a phone, 5K display, or anything in between – gets a version of our image with just enough resolution to look great on their display.</p><p>Join us next time, when we’ll talk about another, vital, way that images can vary: <em>variable image encoding</em>.</p><a class="anchor" name="demos_and_more"></a><h2><a href="#demos_and_more">Demos and more</a></h2>
<ul>
<li>Cloudinary’s official <a href="http://cloudinary.com/documentation/responsive_images#about_responsive_images" data-popup="true">responsive images documentation</a></li>
<li><a href="http://cloudinary.com/blog/responsive_images_with_srcset_sizes_and_cloudinary" data-popup="true">An in-depth tutorial on using <code>srcset</code>, <code>sizes</code>, and Cloudinary</a>.</li>
<li><a href="http://cloudinary.com/blog/how_to_automatically_create_images_for_responsive_design" data-popup="true">An introduction</a> to Cloudinary’s Javascript-based responsive images solution.</li>
<li><a href="https://dev.opera.com/articles/native-responsive-images#variable-width-images" data-popup="true" rel="nofollow">Yoav Weiss on variable-width images</a></li>
<li>The <a href="https://cloudfour.com/thinks/responsive-images-101-part-4-srcset-width-descriptors/" data-popup="true" rel="nofollow">srcset</a>, <a href="https://cloudfour.com/thinks/responsive-images-101-part-5-sizes/" data-popup="true" rel="nofollow"><code>sizes</code></a>, and <a href="https://cloudfour.com/thinks/responsive-images-101-part-9-image-breakpoints/" data-popup="true" rel="nofollow">responsive image breakpoints</a> sections of Jason Grigsby’s 10-part <cite>Responsive Images 101</cite> series (already linked above, but down here again, for good measure!)</li>
<li>A <a href="http://cloudinary.com/blog/jason_grigsby_on_responsive_images_where_it_all_started" data-popup="true">three</a> <a href="http://cloudinary.com/blog/jason_grigsby_on_responsive_images_a_look_at_today_s_solutions" data-popup="true">part</a> <a href="http://cloudinary.com/blog/jason_grigsby_on_responsive_images_gazing_into_the_crystal_ball" data-popup="true">interview</a> with Jason, about the history and future of responsive images.</li>
<li>Cloudinary’s <a href="http://cloudinary.com/blog/introducing_intelligent_responsive_image_breakpoints_solutions" data-popup="true">introduction</a> and <a href="http://cloudinary.com/blog/push_button_art_direction_with_cloudinary_s_responsive_image_breakpoints_generator" data-popup="true">update</a> to the <a href="http://responsivebreakpoints.com" data-popup="true" rel="nofollow">Responsive Images Breakpoint Generator</a>.</li>
<li>Finally, as a bit of advanced-topics extra credit: yours truly on <a href="http://cloudinary.com/blog/automatic_responsive_images_with_client_hints" data-popup="true">making the complexity of <code>srcset</code> the server’s problem using <code>w_auto</code> and Client Hints</a>.</li>
</ul>
]]>
      </description>
      <author />
      <pubDate>Mon, 13 Feb 2017 16:13:11 +0000</pubDate>
      <link>http://cloudinary.com/blog/responsive_images_guide_part_2_variable_image_resolution</link>
      <guid>http://cloudinary.com/blog/responsive_images_guide_part_2_variable_image_resolution</guid>
    </item>
    <item>
      <title>The many faces of on-the-fly face detection</title>
      <description>
        <![CDATA[<p><img alt="smiley overlays on detected faces" height="1158" src="http://res.cloudinary.com/cloudinary/image/upload/face_coaster_cover2.jpg" style="margin: 0 auto;display: block" title="smiley overlays on detected faces" width="1920" /></p><p>With the decreasing price-performance ratio of computing, research efforts in <strong>face detection</strong> and <strong>face recognition</strong> algorithms are rapidly expanding and new techniques for both of these are achieving greater accuracy and reduced processing time.</p><p><strong>Face detection</strong> is a technology that identifies whether and where human faces are located in digital images. It’s commonly used in cameras, security applications, graphic applications, and a variety of other web and mobile apps. It is also a prerequisite for face recognition, which uses a database and additional algorithms to match a detected face with a specific individual.</p><p>A large percentage of the images in most websites and apps include <strong>photos of people</strong> -- from profile pics to news articles to group selfies. These photos need to be displayed in sizes, shapes, and styles that match the site design. Performing automatic face cropping or otherwise programmatically modifying images that contain faces necessitates a reliable face detection mechanism. 
The reliability can be affected by the colors, or lack of colors in the image, the direction a person is facing, the tilt of the head, the size of a face, the complexity of the background, lighting, and more. </p><p>Cloudinary provides a complete image and video management solution for web and mobile app programmers. Our solution includes a <strong>built-in image face detection</strong> functionality and several face-detection features you can take advantage of in your own apps. In most cases, applying this functionality is just a question of adding a parameter or two to your image delivery URLs… and your own creativity, of-course.</p><p>Cloudinary recently updated its face detection mechanism. The new mechanism is now <strong>very efficient and precise</strong>, including many &quot;difficult&quot; scenarios such as side portraits, blurry faces, tricky lighting, and more. </p><p>For example, the people in these images are now easily detected despite low lighting, unusual shadows, black and white images, turned heads and closed eyes:</p><p><img alt="low-lighting face detected" height="267" src="http://res.cloudinary.com/cloudinary/image/upload/w_400/dark_portrait_detected.jpg" style="margin: 0 auto;display: block;float: left" title="low-lighting face detected" width="400" />
<br style="clear:both">&nbsp;</br>
<img alt="face in shadow detected" height="264" src="http://res.cloudinary.com/cloudinary/image/upload/w_400/man-shadow_detected.jpg" style="margin: 0 auto;display: block" title="face in shadow detected" width="400" />
<br/>
<img alt="side-facing, black and white faces detected" height="265" src="http://res.cloudinary.com/cloudinary/image/upload/w_400/side_bw_detected.jpg" style="margin: 0 auto;display: block;float: right" title="side-facing, black and white faces detected" width="400" />
<p style="clear:both">&nbsp;</p>
When you deliver an image URL that includes face-detection manipulations, the faces in the original photo are detected on-the-fly, the requested manipulations are performed in the cloud, and then the final image is delivered via CDN.</p><p>The rest of this blog will cover some of the many ways that developers can automatically manipulate proprietary and user-generated photos containing faces to fit the needs and design of a website or app. </p><a class="anchor" name="facing_it_head_on"></a><h2><a href="#facing_it_head_on">Facing it head on</a></h2><p>Perhaps one of the most common uses of face detection is for cropping. A large percentage of images, especially with user-generated content, contain photos of people. </p><p>Headshots are needed for profile pictures, chat heads, and more, but the original uploaded photo may include much more than just a face, and that face may not even be the central element in the photo. Group selfies are also popular, and rarely centered, so again, we need to be very careful that even if we crop the photo to a different aspect ratio, we don’t lose any of the crew.</p><p>In short, it’s critical in most situations that when we resize and crop uploaded photos, we keep our users’ faces up front and center. There are a variety of features you can use or combine to ensure this.</p><a class="anchor" name="gravity_is_the_key"></a><h3><a href="#gravity_is_the_key">Gravity is the key</a></h3><p>When cropping photos intended for profile pictures or other headshots, you will usually want to use <code>face</code> as your cropping <code>gravity</code> (<code>g_face</code> in URLs). This ensures that the detected face (or largest face if there is more than one) will be the center of the cropped photo, regardless of its initial location.</p><p>If in conjunction with <code>face</code> gravity, you use <code>thumb</code> as your <code>crop</code> method, you will get a crop that’s as tight as possible (given the cropping dimensions) to the detected face coordinates. </p><p>You can further adjust your thumbnail cropping by setting a <code>zoom</code> value, to zoom in or out from the detected face coordinates. And then of-course you can add any other transformations you want.</p>
<div style="clear: both; margin-bottom: 20px">
</div>

<div style="text-align:center;">

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/h_200/teen_facedown" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/h_200/teen_facedown" alt="Original photo" title="Original photo" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Original photo</font></i>

</span><span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_fill/teen_facedown" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_fill/teen_facedown" alt="Cropped to a square using face detection" title="Cropped to a square using face detection" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Cropped to a square using face detection</font></i>
</span>

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb/teen_facedown" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb/teen_facedown" alt="Cropped using face detection with thumbnail cropping" title="Cropped using face detection with thumbnail cropping" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Cropped using face detection<br/>with thumbnail cropping</font></i> 
</span>

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb,z_0.65/teen_facedown" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb,z_0.65/teen_facedown" alt="Face detection, thumbnail crop, zoomed out a bit" title="Face detection, thumbnail crop, zoomed out a bit" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Face detection, thumbnail crop,<br/>zoomed out a bit</font></i>
</span>

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_improve/e_shadow/teen_facedown" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_improve/e_shadow/teen_facedown" alt="Same as previous with circle shape, shadow, and improve effect" title="Same as previous with circle shape, shadow, and improve effect" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Same as previous with circle shape,<br/>shadow, and improve effect</font></i>
</span>

</div>

<div style="clear: both; margin-bottom: 20px">
</div>
<p>Here&#39;s what the delivery code looks like for that last photo:
<div class="example multi_code "><a class="anchor" name="face_thumb_zoomed_out_circle_shape_improve_effect_shadow"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_improve/e_shadow/teen_facedown" 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">w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_improve/e_shadow/</span><span class="public_id">teen_facedown</span></a></span></code></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">teen_facedown</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:width</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:height</span>=&gt;<span style="color:#00D">200</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:zoom</span>=&gt;<span style="color:#60E">0.65</span>, <span style="color:#A60">:radius</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">improve</span><span style="color:#710">&quot;</span></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">thumb</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow</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">teen_facedown</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">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">200</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">200</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">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">zoom</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#60E">0.65</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="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</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">effect</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">improve</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">thumb</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">effect</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">shadow</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">teen_facedown</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">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">200</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">200</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">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">zoom</span><span style="color:#710">&quot;</span></span>: <span style="color:#60E">0.65</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="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</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">effect</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">improve</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>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">thumb</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">effect</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">shadow</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">teen_facedown</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">&quot;</span><span style="color:#D20">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.65</span>, <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</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">improve</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">thumb</span><span style="color:#710">&quot;</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">shadow</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()
  .width(<span style="color:#00D">200</span>).height(<span style="color:#00D">200</span>).gravity(<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>).zoom(<span style="color:#60E">0.65</span>).radius(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</span></span>).effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">improve</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">thumb</span><span style="color:#710">&quot;</span></span>).chain()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow</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">teen_facedown</span><span style="color:#710">&quot;</span></span>)</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">teen_facedown</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">&quot;</span><span style="color:#D20">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.65</span>, <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</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">improve</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">thumb</span><span style="color:#710">&quot;</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">shadow</span><span style="color:#710">&quot;</span></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(new Transformation()
  .Width(200).Height(200).Gravity(&quot;face&quot;).Zoom(0.65).Radius(&quot;max&quot;).Effect(&quot;improve&quot;).Crop(&quot;thumb&quot;).Chain()
  .Effect(&quot;shadow&quot;)).BuildImageTag(&quot;teen_facedown&quot;)</pre></div>
</div>
</div></div></div></div></p><p>Everything mentioned above works equally well for multiple faces. Just use <code>faces</code> gravity instead of <code>face</code>, and your cropping will be based on a rectangle that includes all detected faces.</p><p>All of this assumes you can reasonably expect that the uploaded image is going to contain one or multiple faces as the main subject. </p><p>Sometimes the main subject of an image isn&#39;t necessarily expected to be a person, but you still need to ensure you aren’t cutting off people or other important content of the image. In this case, you can take advantage of the <code>auto</code> gravity feature. With this automated cropping method, the most prominent elements of the picture determine the cropping coordinates. Unless otherwise specified, any detected <code>faces</code> get a high priority in this cropping decision, but other prominent elements are also included. </p><p>You can learn lots more about <code>auto</code> gravity in this <a href="https://cloudinary.com/blog/smart_automatic_image_cropping_maybe_you_can_always_get_what_you_want" data-popup="true">blog article</a> and this <a href="http://cloudinary.com/documentation/image_transformations#automatic_cropping" data-popup="true">documentation</a>. </p><a class="anchor" name="losing_face"></a><h2><a href="#losing_face">Losing face</a></h2><p>There may be situations where you&#39;d like to keep the people in a photograph anonymous. In these cases, you can pixelate or blur all detected faces just by adding a single parameter to your image URL.</p><p>In the example below, the faces that Cloudinary detects in the concert audience are generally those that could likely be identified by a human viewer. All of these faces are automatically blurred before the image is delivered, using the <code>blur_faces</code> effect.</p><p><div class="example multi_code "><a class="anchor" name="blurred_faces"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/e_blur_faces:500/concert_crowd" 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">e_blur_faces:500/</span><span class="public_id">concert_crowd</span></a></span></code></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">concert_crowd</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">blur_faces:500</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">concert_crowd</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">effect</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">blur_faces:500</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">concert_crowd</span><span style="color:#710">&quot;</span></span>).image(effect=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">blur_faces:500</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">concert_crowd</span><span style="color:#710">&quot;</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">blur_faces:500</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().effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">blur_faces:500</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">concert_crowd</span><span style="color:#710">&quot;</span></span>)</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">concert_crowd</span><span style="color:#710">&quot;</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">blur_faces:500</span><span style="color:#710">&quot;</span></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(new Transformation().Effect(&quot;blur_faces:500&quot;)).BuildImageTag(&quot;concert_crowd&quot;)</pre></div>
</div>
</div></div></div></div><a href="http://res.cloudinary.com/demo/image/upload/e_blur_faces:500/concert_crowd" data-popup="true"><img alt="blurred faces" height="333" src="http://res.cloudinary.com/demo/image/upload/e_blur_faces:500/w_500/concert_crowd" style="margin: 0 auto;display: block" title="blurred faces" width="500" /></a></p><p>And here’s an example of an ice skating scene where a couple of childrens&#39; faces are clearly visible. This time, we use the pixelate option to protect the kids’ identities:</p><p><div class="example multi_code "><a class="anchor" name="pixelated_faces"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/c_scale,e_pixelate_faces:4,w_500/ice_skating.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">c_scale,e_pixelate_faces:4,w_500/</span><span class="public_id">ice_skating.jpg</span></a></span></code></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">ice_skating.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate_faces:4</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">500</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>)</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">ice_skating.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">effect</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">pixelate_faces:4</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">500</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>))</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">ice_skating.jpg</span><span style="color:#710">&quot;</span></span>).image(effect=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate_faces:4</span><span style="color:#710">&quot;</span></span>, width=<span style="color:#00D">500</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>)</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">ice_skating.jpg</span><span style="color:#710">&quot;</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">pixelate_faces:4</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">500</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>})</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().effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate_faces:4</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#00D">500</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>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ice_skating.jpg</span><span style="color:#710">&quot;</span></span>)</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">ice_skating.jpg</span><span style="color:#710">&quot;</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">pixelate_faces:4</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">500</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>})</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(new Transformation().Effect(&quot;pixelate_faces:4&quot;).Width(500).Crop(&quot;scale&quot;)).BuildImageTag(&quot;ice_skating.jpg&quot;)</pre></div>
</div>
</div></div></div></div><a href="http://res.cloudinary.com/demo/image/upload/c_scale,e_pixelate_faces:4,w_500/ice_skating.jpg" data-popup="true"><img alt="pixelated faces" height="334" src="http://res.cloudinary.com/demo/image/upload/c_scale,e_pixelate_faces:4,w_500/ice_skating.jpg" style="margin: 0 auto;display: block" title="pixelated faces" width="500" /></a></p><p><strong>Tip</strong>: For cases like these, you may want to take advantage of one of the <a href="http://cloudinary.com/documentation/image_transformations#control_access_to_images" data-popup="true">access control options</a> to prevent users from accessing the non-blurred or non-pixelated versions of the image.</p><a class="anchor" name="saving_face"></a><h2><a href="#saving_face">Saving face</a></h2><p>There’s no such thing as a face detection mechanism that will detect 100% of the faces 100% of the time, so what if you notice that a particular face you need was not detected? No problem. You can always update the detected coordinates explicitly.</p><p>For example, when a user uploads an image to your site, you can retrieve and display the detected face coordinates and then enable your users to adjust the coordinates or add a new face via your UI. You can then pass the updated coordinates to Cloudinary via the <a href="http://cloudinary.com/documentation/admin_api#update_resources" data-popup="true">Update</a> method of the Admin API.</p><p>For your own images, you can also manually change the coordinates using the Media library UI.</p><a class="anchor" name="in_your_face"></a><h2><a href="#in_your_face">In your face</a></h2><p>Sometimes, just blurring or pixelating a face isn’t enough. Instead, you want to completely cover the face with another image. Or, maybe you just want to add a fun mask. Whatever the reason, it’s simple to add the same image to all faces in a photo.</p><p>To do this, you take advantage of the <code>region_relative</code> flag and <code>faces</code> gravity when you specify the overlay image. That tells Cloudinary that you want the overlay to be placed on all faces, and that the specified size of each overlay is a percentage relative to the size of each detected face.</p><p>For example, here’s a quick way to get your family dressed up in costume:
<div class="example multi_code "><a class="anchor" name="family_with_spiderman_masks"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/g_faces,l_spiderman_mask,w_1.1,fl_region_relative,g_faces/family_portrait.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">g_faces,l_spiderman_mask,w_1.1,fl_region_relative,g_faces/</span><span class="public_id">family_portrait.jpg</span></a></span></code></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">family_portrait.jpg</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">faces</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">spiderman_mask</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#60E">1.1</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">region_relative</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">family_portrait.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">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">faces</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">spiderman_mask</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:#60E">1.1</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">region_relative</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">family_portrait.jpg</span><span style="color:#710">&quot;</span></span>).image(gravity=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">faces</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">spiderman_mask</span><span style="color:#710">&quot;</span></span>, width=<span style="color:#60E">1.1</span>, flags=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">region_relative</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">family_portrait.jpg</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">faces</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">spiderman_mask</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.1</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">region_relative</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().gravity(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">faces</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">spiderman_mask</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#60E">1.1</span>).flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">region_relative</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">family_portrait.jpg</span><span style="color:#710">&quot;</span></span>)</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">family_portrait.jpg</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">faces</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">spiderman_mask</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.1</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">region_relative</span><span style="color:#710">&quot;</span></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(new Transformation().Gravity(&quot;faces&quot;).Overlay(&quot;spiderman_mask&quot;).Width(1.1).Flags(&quot;region_relative&quot;)).BuildImageTag(&quot;family_portrait.jpg&quot;)</pre></div>
</div>
</div></div></div></div></p>
<div style="clear: both; margin-bottom: 20px">
</div>

<div style="text-align:center;">

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/family_portrait" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/w_300/family_portrait" alt="Original photo" title="Original photo" style="margin-right: 10px;display:block;" /></a>

</span><span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/g_faces,l_spiderman_mask,w_1.1,fl_region_relative,g_faces/family_portrait" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/g_faces,l_spiderman_mask,w_1.1,fl_region_relative,g_faces/w_300/family_portrait" alt="spiderman mask overlay on faces" title="spiderman mask overlay on faces" style="margin-right: 10px;display:block;" /></a>
</span>

</div>

<div style="clear: both; margin-bottom: 20px">
</div>
<p>You probably already noticed that we gave anonymous (happy) faces to our roller coaster riders at the beginning of this article using the same technique.</p><p>And remember, the overlay you use doesn’t have to cover the whole face or even be centered. Below, we add a ranger hat to a man’s head using a relative y- coordinate to offset the location of the hat about 30% above the center of the face.</p><p><div class="example multi_code "><a class="anchor" name="hat_overlay"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/c_crop,g_face,z_0.6/l_ranger_hat,w_1.1,fl_region_relative,g_face,y_-0.3/smiling_man" 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">c_crop,g_face,z_0.6/l_ranger_hat,w_1.1,fl_region_relative,g_face,y_-0.3/</span><span class="public_id">smiling_man</span></a></span></code></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">smiling_man</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:zoom</span>=&gt;<span style="color:#60E">0.6</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">crop</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">ranger_hat</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#60E">1.1</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">region_relative</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:y</span>=&gt;<span style="color:#60E">-0.3</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">smiling_man</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">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">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">zoom</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#60E">0.6</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">crop</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">ranger_hat</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:#60E">1.1</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">region_relative</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">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">y</span><span style="color:#710">&quot;</span></span>=&gt;-<span style="color:#60E">0.3</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">smiling_man</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">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">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">zoom</span><span style="color:#710">&quot;</span></span>: <span style="color:#60E">0.6</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">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">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">ranger_hat</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:#60E">1.1</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">region_relative</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">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">y</span><span style="color:#710">&quot;</span></span>: -<span style="color:#60E">0.3</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">smiling_man</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.6</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">crop</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">ranger_hat</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.1</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">region_relative</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">y</span>: -<span style="color:#60E">0.3</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()
  .gravity(<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>).zoom(<span style="color:#60E">0.6</span>).crop(<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>).chain()
  .overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">ranger_hat</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#60E">1.1</span>).flags(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">region_relative</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">face</span><span style="color:#710">&quot;</span></span>).y(-<span style="color:#60E">0.3</span>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">smiling_man</span><span style="color:#710">&quot;</span></span>)</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">smiling_man</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.6</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">crop</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">ranger_hat</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.1</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">region_relative</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">y</span>: -<span style="color:#60E">0.3</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(new Transformation()
  .Gravity(&quot;face&quot;).Zoom(0.6).Crop(&quot;crop&quot;).Chain()
  .Overlay(&quot;ranger_hat&quot;).Width(1.1).Flags(&quot;region_relative&quot;).Gravity(&quot;face&quot;).Y(-0.3)).BuildImageTag(&quot;smiling_man&quot;)</pre></div>
</div>
</div></div></div></div><a href="http://res.cloudinary.com/demo/image/upload/c_crop,g_face,z_0.6/l_ranger_hat,w_1.1,fl_region_relative,g_face,y_-0.3/smiling_man" data-popup="true"><img alt="hat overlay" height="359" src="http://res.cloudinary.com/demo/image/upload/c_crop,g_face,z_0.6/l_ranger_hat,w_1.1,fl_region_relative,g_face,y_-0.3/w_300/smiling_man" style="margin: 0 auto;display: block" title="hat overlay" width="300" /></a></p><a class="anchor" name="at_face_value"></a><h2><a href="#at_face_value">At face value</a></h2><p>If you want to check the face detection status of uploaded images programmatically, you can request to return face coordinate data when you or your users <a href="http://cloudinary.com/documentation/image_upload_api_reference#upload" data-popup="true">upload</a> images, or you can request them upon demand for already uploaded images using the <a href="http://cloudinary.com/documentation/image_upload_api_reference#explicit" data-popup="true">explicit</a> method of the upload API, or with the <a href="http://cloudinary.com/documentation/admin_api#details_of_a_single_resource" data-popup="true">list details of a single resource</a> functionality of the Admin API. The following shows an excerpt from the JSON response of an upload call where the <code>faces</code> parameter was set to true.</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">faces</span><span style="color:#710">&quot;</span></span>:  [ [<span style="color:#00D">513</span>, <span style="color:#00D">19</span>, <span style="color:#00D">38</span>, <span style="color:#00D">52</span>], [<span style="color:#00D">409</span>, <span style="color:#00D">26</span>, <span style="color:#00D">40</span>, <span style="color:#00D">54</span>], [<span style="color:#00D">79</span>, <span style="color:#00D">31</span>, <span style="color:#00D">43</span>, <span style="color:#00D">59</span>], [<span style="color:#00D">232</span>, <span style="color:#00D">32</span>, <span style="color:#00D">40</span>, <span style="color:#00D">54</span>], [<span style="color:#00D">321</span>, <span style="color:#00D">33</span>, <span style="color:#00D">41</span>, <span style="color:#00D">57</span>], [<span style="color:#00D">160</span>, <span style="color:#00D">37</span>, <span style="color:#00D">43</span>, <span style="color:#00D">59</span>]
}</pre></div>
</div>
</div></div><p>For example, you could use this data to calculate the ideal location for a text overlay so that it won’t cover any faces on a photo.</p><a class="anchor" name="two_faced"></a><h2><a href="#two_faced">Two-faced</a></h2><p>Cloudinary enables you to create programmatically complex manipulations by adding conditions to your transformations. One of the things you can base your conditions on is <code>face_count</code>.</p><p>For example, you can’t always be sure that a profile picture will be of a person. Some people choose to upload family portraits, scenery, or other images to represent themselves. The following images use the identical conditional transformation, where thumbnail cropping is applied if one or more faces is found, but scaled cropping is used on images without faces. We’ve also added a shadow vs black border for the alternative conditions to highlight the differences. </p><p>(The code shown here is for the <code>nice_couple</code> on the left, but you can click the bridge picture to see that it uses the identical transformation URL except for the image name (public ID).)</p><p><div class="example multi_code "><a class="anchor" name="conditional_transformation_based_on_face_count"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/if_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/nice_couple" 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_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/</span><span class="public_id">nice_couple</span></a></span></code></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">nice_couple</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">fc_gte_1</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">faces</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:zoom</span>=&gt;<span style="color:#60E">0.5</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:height</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow:10</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:color</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#acb2b9</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:x</span>=&gt;<span style="color:#00D">7</span>, <span style="color:#A60">:y</span>=&gt;<span style="color:#00D">7</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">thumb</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">:width</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:height</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:border</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">3px_solid_black</span><span style="color:#710">&quot;</span></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>}
  ])</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">nice_couple</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">fc_gte_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">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">faces</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">zoom</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#60E">0.5</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">200</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">200</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">shadow:10</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">color</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">#acb2b9</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">x</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">7</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">y</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">7</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">thumb</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="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">200</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">200</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">border</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">3px_solid_black</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>)
  )))</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">nice_couple</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">fc_gte_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">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">faces</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">zoom</span><span style="color:#710">&quot;</span></span>: <span style="color:#60E">0.5</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">200</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">200</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">shadow:10</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">color</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">#acb2b9</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">x</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">7</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">y</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">7</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">thumb</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">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">200</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">200</span>, <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">border</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">3px_solid_black</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>: <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>}
  ])</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">nice_couple</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">fc_gte_1</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">faces</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.5</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">effect</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow:10</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#acb2b9</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">x</span>: <span style="color:#00D">7</span>, <span style="color:#606">y</span>: <span style="color:#00D">7</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">thumb</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">width</span>: <span style="color:#00D">200</span>, <span style="color:#606">height</span>: <span style="color:#00D">200</span>, <span style="color:#606">border</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">3px_solid_black</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>}
  ]})</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">fc_gte_1</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">faces</span><span style="color:#710">&quot;</span></span>).zoom(<span style="color:#60E">0.5</span>).width(<span style="color:#00D">200</span>).height(<span style="color:#00D">200</span>).effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow:10</span><span style="color:#710">&quot;</span></span>).color(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#acb2b9</span><span style="color:#710">&quot;</span></span>).x(<span style="color:#00D">7</span>).y(<span style="color:#00D">7</span>).crop(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">thumb</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>).width(<span style="color:#00D">200</span>).height(<span style="color:#00D">200</span>).border(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">3px_solid_black</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>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">nice_couple</span><span style="color:#710">&quot;</span></span>)</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">nice_couple</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">fc_gte_1</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">faces</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.5</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">effect</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow:10</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#acb2b9</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">x</span>: <span style="color:#00D">7</span>, <span style="color:#606">y</span>: <span style="color:#00D">7</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">thumb</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">width</span>: <span style="color:#00D">200</span>, <span style="color:#606">height</span>: <span style="color:#00D">200</span>, <span style="color:#606">border</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">3px_solid_black</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>}
  ]})</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(new Transformation()
  .If(&quot;fc_gte_1&quot;).Gravity(&quot;faces&quot;).Zoom(0.5).Width(200).Height(200).Effect(&quot;shadow:10&quot;).Color(&quot;#acb2b9&quot;).X(7).Y(7).Crop(&quot;thumb&quot;).Chain()
  .If(&quot;else&quot;).Width(200).Height(200).Border(&quot;3px_solid_black&quot;).Crop(&quot;scale&quot;)).BuildImageTag(&quot;nice_couple&quot;)</pre></div>
</div>
</div></div></div></div></p>
<div style="clear: both; margin-bottom: 20px">
</div>

<div style="text-align:center;">

<span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/if_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/nice_couple" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/if_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/nice_couple" alt="image with one or more faces" title="image with one or more faces" style="margin-right: 10px;display:block;" /></a>

</span><span style="display:inline-block;">
<a href="http://res.cloudinary.com/demo/image/upload/if_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/golden_gate" target ="_blank"><img src="http://res.cloudinary.com/demo/image/upload/if_fc_gte_1,g_faces,c_thumb,z_0.50,w_200,h_200,e_shadow:10,co_rgb:acb2b9,x_7,y_7/if_else,w_200,h_200,bo_3px_solid_black/golden_gate" alt="image without faces" title="image without faces" style="margin-right: 10px;display:block;" /></a>
</span>

</div>

<div style="clear: both; margin-bottom: 20px">
</div>
<p>You can learn more about conditional transformations <a href="http://cloudinary.com/documentation/image_transformations#conditional_transformations" data-popup="true">here</a>.</p><a class="anchor" name="face_to_face"></a><h2><a href="#face_to_face">Face to face</a></h2><p>Just a reminder that in addition to applying all this cool stuff on images that you or your users directly upload, you can also use the same tricks with remotely <a href="http://cloudinary.com/documentation/fetch_remote_images" data-popup="true">fetched</a> images, such as <a href="http://cloudinary.com/documentation/facebook_profile_pictures" data-popup="true">Facebook profile pictures</a>.</p><p>For example, you can allow your users to select to use their Facebook profile photo as the basis for their account profile photo in your app and then apply resizing, rounding, artistic effects, or any other transformation to fit your site&#39;s art direction, while ensuring that the detected face of the fetched photo remains the main focus of the final photo.</p><p>Here we apply cropping and several other transformations to the Facebook profile photo from the <strong>Remembering JFK</strong> page:</p><p><div class="example multi_code "><a class="anchor" name="jfk_with_transformations"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/facebook/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_art:sizzle/e_shadow/268587306614095" data-popup="true"><span class="prefix">http://res.cloudinary.com/demo/</span><span class="kind">image/facebook/</span><span class="signature"></span><span class="trans">w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_art:sizzle/e_shadow/</span><span class="public_id">268587306614095</span></a></span></code></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">268587306614095</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">facebook</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:width</span>=&gt;<span style="color:#00D">200</span>, <span style="color:#A60">:height</span>=&gt;<span style="color:#00D">200</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">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:zoom</span>=&gt;<span style="color:#60E">0.65</span>, <span style="color:#A60">:radius</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">art:sizzle</span><span style="color:#710">&quot;</span></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">thumb</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow</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">268587306614095</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">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">facebook</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">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">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">200</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">200</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">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">zoom</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#60E">0.65</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="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</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">effect</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">art:sizzle</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">thumb</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">effect</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">shadow</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">268587306614095</span><span style="color:#710">&quot;</span></span>).image(type=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">facebook</span><span style="color:#710">&quot;</span></span>, transformation=[
  {<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">200</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">200</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">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">zoom</span><span style="color:#710">&quot;</span></span>: <span style="color:#60E">0.65</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="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</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">effect</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">art:sizzle</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>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">thumb</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">effect</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">shadow</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">268587306614095</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">facebook</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">transformation</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">&quot;</span><span style="color:#D20">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.65</span>, <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</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">art:sizzle</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">thumb</span><span style="color:#710">&quot;</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">shadow</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()
  .width(<span style="color:#00D">200</span>).height(<span style="color:#00D">200</span>).gravity(<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>).zoom(<span style="color:#60E">0.65</span>).radius(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</span></span>).effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">art:sizzle</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">thumb</span><span style="color:#710">&quot;</span></span>).chain()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">shadow</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">facebook</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">268587306614095</span><span style="color:#710">&quot;</span></span>)</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">268587306614095</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">facebook</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">transformation</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">&quot;</span><span style="color:#D20">face</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">zoom</span>: <span style="color:#60E">0.65</span>, <span style="color:#606">radius</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">max</span><span style="color:#710">&quot;</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">art:sizzle</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">thumb</span><span style="color:#710">&quot;</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">shadow</span><span style="color:#710">&quot;</span></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(new Transformation()
  .Width(200).Height(200).Gravity(&quot;face&quot;).Zoom(0.65).Radius(&quot;max&quot;).Effect(&quot;art:sizzle&quot;).Crop(&quot;thumb&quot;).Chain()
  .Effect(&quot;shadow&quot;)).Type(&quot;facebook&quot;).BuildImageTag(&quot;268587306614095&quot;)</pre></div>
</div>
</div></div></div></div></p>
<div style="clear: both; margin-bottom: 20px">
</div>

<div style="text-align:center;">

<span style="display:inline-block; margin-right:40px">
<a href="http://res.cloudinary.com/demo/image/facebook/268587306614095" target ="_blank"><img src="http://res.cloudinary.com/demo/image/facebook/h_200/268587306614095" alt="Original FB profile photo" title="Original FB profile photo" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1"><br/><br/>Original Facebook profile photo</font></i>

</span><span style="display:inline-block;">
&nbsp;&nbsp;&nbsp;&nbsp;
<a href="http://res.cloudinary.com/demo/image/facebook/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_art:sizzle/e_shadow/268587306614095" target ="_blank"><img src="http://res.cloudinary.com/demo/image/facebook/w_200,h_200,g_face,c_thumb,z_0.65,r_max,e_art:sizzle/e_shadow/268587306614095" alt="Cropped to a circle using face detection" title="Cropped to a circle using face detection" style="margin-right: 10px;display:block;" /></a>
<i><font size="-1">Manipulated photo: face thumbnail<br/>slight zoom,
artistic filter,<br/>rounding, shadow</font></i>
</span>

</div>

<div style="clear: both; margin-bottom: 20px">
</div>
<p>You can do the same with images fetched from other sites, like <a href="http://cloudinary.com/documentation/twitter_profile_pictures" data-popup="true">Twitter</a>, <a href="http://cloudinary.com/blog/display_instagram_and_google_profile_pictures_in_your_website_and_mobile_app" data-popup="true">Google+</a>, or from any image URL.</p><a class="anchor" name="face_the_facts"></a><h2><a href="#face_the_facts">Face the facts</a></h2><p>By now, the many potential uses for face detection have probably become obvious to you, <i>as plain as the nose on your face</i>, you might say….   OK, I&#39;m done with the painful face puns.</p><p>The fact is that almost every Website includes both local and user-generated content that centers around people. It’s essential that those people remain the focus of the displayed pictures regardless of how you resize, crop, add images and text overlays, etc. </p><p>Cloudinary’s face detection capabilities and updated mechanism enable you to accomplish all of these things programmatically, using simple transformation parameters, and with very reliable results. </p><p>Ready to see how far your creativity can take these face detection features? These features are available in all plans including the free plan, with no add-ins required. If you don’t have a Cloudinary account yet, you can <a href="https://cloudinary.com/users/register/free" data-popup="true">sign up for a free one</a>, and give it a go!</p>]]>
      </description>
      <author />
      <pubDate>Wed, 08 Feb 2017 15:37:38 +0000</pubDate>
      <link>http://cloudinary.com/blog/the_many_faces_of_on_the_fly_face_detection</link>
      <guid>http://cloudinary.com/blog/the_many_faces_of_on_the_fly_face_detection</guid>
    </item>
    <item>
      <title>Explore Image Management Best Practices at ImageCon</title>
      <description>
        <![CDATA[<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:AllowPNG/>
 </o:OfficeDocumentSettings>
</xml><![endif]--> <!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:TrackMoves/>
  <w:TrackFormatting/>
  <w:PunctuationKerning/>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-US</w:LidThemeOther>
  <w:LidThemeAsian>JA</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:EnableOpenTypeKerning/>
   <w:DontFlipMirrorIndents/>
   <w:OverrideTableStyleHps/>
   <w:UseFELayout/>
  </w:Compatibility>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   <m:brkBinSub m:val="&#45;-"/>
   <m:smallFrac m:val="off"/>
   <m:dispDef/>
   <m:lMargin m:val="0"/>
   <m:rMargin m:val="0"/>
   <m:defJc m:val="centerGroup"/>
   <m:wrapIndent m:val="1440"/>
   <m:intLim m:val="subSup"/>
   <m:naryLim m:val="undOvr"/>
  </m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false"
  DefSemiHidden="false" DefQFormat="false" DefPriority="99"
  LatentStyleCount="382">
  <w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 9"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 1"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 2"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 3"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 4"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 5"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 6"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 7"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 8"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 9"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footnote text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="header"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footer"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index heading"/>
  <w:LsdException Locked="false" Priority="35" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="table of figures"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="envelope address"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="envelope return"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footnote reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="line number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="page number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="endnote reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="endnote text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="table of authorities"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="macro"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="toa heading"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 5"/>
  <w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Closing"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Signature"/>
  <w:LsdException Locked="false" Priority="1" SemiHidden="true"
   UnhideWhenUsed="true" Name="Default Paragraph Font"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Message Header"/>
  <w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Salutation"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Date"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text First Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text First Indent 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Heading"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Block Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Hyperlink"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="FollowedHyperlink"/>
  <w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Document Map"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Plain Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="E-mail Signature"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Top of Form"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Bottom of Form"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal (Web)"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Acronym"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Address"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Cite"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Code"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Definition"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Keyboard"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Preformatted"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Sample"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Typewriter"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Variable"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal Table"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation subject"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="No List"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Contemporary"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Elegant"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Professional"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Subtle 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Subtle 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Balloon Text"/>
  <w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Theme"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Level 9"/>
  <w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
  <w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
  <w:LsdException Locked="false" Priority="34" QFormat="true"
   Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" QFormat="true"
   Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" QFormat="true"
   Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" QFormat="true"
   Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" QFormat="true"
   Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" QFormat="true"
   Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
  <w:LsdException Locked="false" Priority="37" SemiHidden="true"
   UnhideWhenUsed="true" Name="Bibliography"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
  <w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
  <w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
  <w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
  <w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
  <w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
  <w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
  <w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
  <w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
  <w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 1"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 2"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 3"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 4"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 5"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 6"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
  <w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
  <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 1"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 2"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 3"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 4"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 5"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 6"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Mention"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Smart Hyperlink"/>
 </w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
 /* Style Definitions */
table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:Cambria;
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:minor-latin;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:minor-latin;}
</style>
<![endif]--> <!--StartFragment-->
<p class="MsoNormal"><span style="font-family: Calibri;"><img src="http://res.cloudinary.com/cloudinary/image/upload/w_700/imagecon_blog_post.jpg" alt="ImageCon_Header" width="700" height="368"></span></p>
<p class="MsoNormal"><span style="font-family: arial, helvetica, sans-serif;"><strong>Images</strong> – if you’re a developer, there’s no doubt that at one time or another, you’ve probably worked with a lot of image files, and may have been tasked with ensuring a top-notch user experience or continually improving website and app performance. You may have posed questions on online message boards, or sought advice from your developer colleagues. But there hasn’t been a conference that solely focused on image management…until now.</span></p>
<p class="MsoNormal"><span style="font-family: arial, helvetica, sans-serif;"><strong>Introducing <a href="https://www.imagecon.com/" target="_blank">ImageCon</a> – the first-ever event designed to bring together developers for an open, frank discussion of image management challenges.</strong> ImageCon, which takes place Wednesday, March 1, at the Four Seasons in San Francisco – will feature presentations by some of today’s visionaries, leading technologists and developers who will share their thought leadership about best practices, including:</span></p>
<ul>
<li><span style="font-family: arial, helvetica, sans-serif;"><strong><a href="https://www.imagecon.com/agenda/speakers/139032" target="_blank">Vitaly Friedman</a>, </strong><strong>editor-in-chief of Smashing Magazine</strong> – Leading a session called “Reaching for the Stars: Why Images Matter,” Vitaly will discuss why designers struggle with art direction and data visualization when trying to craft a great user experience across various screens and platforms. </span></li>
<li><span style="font-family: arial, helvetica, sans-serif;"><strong><a href="https://www.imagecon.com/agenda/speakers/138863" target="_blank">Jason Grigsby</a>, co-founder of Cloud Four</strong> – In a session on “Delivering Responsive Images,” Jason will outline the hard work ahead now that solutions for responsive images has been integrated with browsers.</span></li>
<li><span style="font-family: arial, helvetica, sans-serif;"><strong><a href="https://www.imagecon.com/agenda/speakers/139662" target="_blank">Tobin Titus</a>, senior program manager at Microsoft</strong> – During “The Physics of Fast: Image Compression,” Tobin will examine how performance best practices are changing as more users shift to lower-cost devices on mobile networks. He’ll cover physical limitations of the devices, choices of graphics formats and how these factors impact the performance of your entire site or application.</span></li>
<li><span style="font-family: arial, helvetica, sans-serif;"><strong><a href="https://www.imagecon.com/agenda/speakers/138748" target="_blank">Steve Souders</a>, chief SpeedCurver at SpeedCurve</strong> – Steve will look at “Measuring Image Performance” in this session, during which he’ll discuss tracking website speed and other best practices for performance measurement, designed to optimize your site and engage users.</span></li>
<li><span style="font-family: arial, helvetica, sans-serif;"><span style="font-family: arial, helvetica, sans-serif;"><strong><a href="https://www.imagecon.com/agenda/speakers/138864" target="_blank">Allison McKnight</a>, senior software engineer for Etsy</strong> – During a session on “Image Performance: Good for Your Users,</span> Good for Your Business,” Allison will share real-world examples of the positive impact image optimization can have on metrics important to your business and end users, and talk about useful tools for enhancing user experience.</span></li>
</ul>
<p class="MsoNormal"><span style="font-family: arial, helvetica, sans-serif;">Cloudinary is very excited about the great line-up of speakers and the opportunity the event presents for the industry as a whole to advance <strong>image management best practices</strong>. We believe you’ll come away with practical advice and solutions that you can employ right away to address the challenges you face in optimizing your website for end users.  </span></p>
<p class="MsoNormal"><span style="font-family: arial, helvetica, sans-serif;">More importantly, we believe this is a great opportunity to <strong>network</strong> with your peers and <strong>learn</strong> from their experiences. Through an open dialogue and sharing real-world experiences, we expect ImageCon to play an important role in advancing – and improving – the practice of image management. </span></p>
<p class="MsoNormal"><span style="font-family: arial, helvetica, sans-serif;"><strong>We hope you’ll join us at ImageCon</strong> – <strong><a href="https://www.imagecon.com/home" target="_blank">register today.</a></strong></span></p>
<!--EndFragment-->]]>
      </description>
      <author />
      <pubDate>Mon, 06 Feb 2017 16:20:32 +0000</pubDate>
      <link>http://cloudinary.com/blog/explore_image_management_best_practices_at_imagecon</link>
      <guid>http://cloudinary.com/blog/explore_image_management_best_practices_at_imagecon</guid>
    </item>
    <item>
      <title>Compressing Cellular Automata</title>
      <description>
        <![CDATA[<p><img alt="Cellular Automata" height="802" src="http://res.cloudinary.com/cloudinary/image/upload/cellular_automata.png" style="margin: 0 auto;display: block" title="Cellular Automata" width="1540" /></p>
<script src="//res.cloudinary.com/cloudinary/raw/upload/flif.js"></script>

<style>
canvas { max-width: 100%; margin: 3px auto; display: block;}
</style>
<p><a href="https://en.wikipedia.org/wiki/Cellular_automaton" data-popup="true" rel="nofollow">Cellular Automata</a> are pretty cool things to play with. There are many, many variants, like <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" data-popup="true" rel="nofollow">Conway’s Game of Life</a>, <a href="https://en.wikipedia.org/wiki/Abelian_sandpile_model" data-popup="true" rel="nofollow">Abelian Sandpiles</a>, <a href="https://en.wikipedia.org/wiki/Langton%27s_loops" data-popup="true" rel="nofollow">Langton’s Loops</a> and <a href="https://en.wikipedia.org/wiki/Brian%27s_Brain" data-popup="true" rel="nofollow">Brian’s Brain</a>, but in this blogpost, I’ll just talk about the simplest kinds of cellular automata: one-dimensional cellular automata.</p><p>The simplest kind of 1D cellular automata are called <a href="https://en.wikipedia.org/wiki/Elementary_cellular_automaton" data-popup="true" rel="nofollow">Elementary Cellular Automata</a>. They work on a sequence of cells, which can each have two possible states: on and off, or 1 and 0. Starting from an initial sequence, the next sequence is computed based on simple rules: the next state of a cell only depends on the current state of the cell itself and its two neighbors.</p><p>For example, here is an elementary cellular automaton called &quot;Rule 22&quot;:</p><p><img alt="Rule 22" height="187" src="https://res.cloudinary.com/cloudinary/image/upload/rule_22.png" style="margin: 0 auto;display: block" title="Rule 22" width="657" /></p><p>In this automaton, a cell is &quot;on&quot; if in the previous generation, exactly one out of those three cells was on; otherwise it is &quot;off&quot;. Rules can be described using the <a href="https://en.wikipedia.org/wiki/Wolfram_code" data-popup="true" rel="nofollow">Wolfram code</a>, which was introduced by <a href="https://en.wikipedia.org/wiki/Stephen_Wolfram" data-popup="true" rel="nofollow">Stephen Wolfram</a>. In the case of elementary cellular automata, there are just 8 = 2<sup>3</sup> possible configurations of a given cell and its neighbors, and for each configuration there are just two options for the resulting new state, so there are 256 = 2<sup>8</sup> different elementary CAs, and they can be described using an 8-bit number. So the rules of the diagram above can be described with the binary number 00010110, or in decimal notation: 22.</p><p>You can draw the evolution of a 1D cellular automaton (CA) as a 2D image, starting with some initial row of cells at the top and then drawing more and more generations in the rows below it. For rule 22, if you start with just a single black cell in the top row, you get the following image after 512 generations:</p><p><canvas data-polyflif-src="https://res.cloudinary.com/jon/CA/r22.flif" width="1025" height="512"></canvas></p><p>Interestingly, the resulting image looks a lot like a <a href="https://en.wikipedia.org/wiki/Sierpinski_triangle" data-popup="true" rel="nofollow">Sierpinski triangle</a>. In fact several of the elementary CAs look like this. It is one of the simplest examples of a <a href="https://en.wikipedia.org/wiki/Fractal" data-popup="true" rel="nofollow">fractal</a>: the image has a self-repeating structure at different scales.</p><a class="anchor" name="compressing_ca_images"></a><h2><a href="#compressing_ca_images">Compressing CA images</a></h2><p>You might expect that an image with so much repetitive structure in it, generated from such a simple rule, must compress very well. And it does. But it depends on the image format.</p><p>As a <a href="https://res.cloudinary.com/jon/CA/r22.jpg" data-popup="true">JPEG</a>, the above image doesn’t compress very well: it weighs 79 KB at quality 90, and that is not even lossless. Even at the lowest possible quality, it is still 16 KB, and at that quality setting, the compression artifacts are quite bad:</p><p><img alt="JPEG Compressed" src="https://res.cloudinary.com/cloudinary/image/upload/ca_jpeg_compressed.jpg" style="margin: 0 auto;display: block"></p><p>As a <a href="https://res.cloudinary.com/jon/CA/r22.png" data-popup="true">PNG</a> however, the image is only 3.4 KB, and that is lossless. So <a href="http://cloudinary.com/blog/how_to_select_the_perfect_image_format" data-popup="true">picking the right format</a> can matter a lot, indeed. If you’re using Cloudinary, you don’t have to worry about that: just use <code>f_auto</code>, <code>q_auto</code> (<a href="http://cloudinary.com/blog/introducing_smart_cropping_intelligent_quality_selection_and_automated_responsive_images" data-popup="true">read more</a>) and you will automatically get the most suitable image format and quality settings – in this case, that would be a lossless PNG.</p><p>In this example, PNG performs very well because there is a lot of exact repetition in the image. PNG is based on the <a href="https://en.wikipedia.org/wiki/DEFLATE" data-popup="true" rel="nofollow">DEFLATE</a> algorithm, which replaces such exact duplicates by backreferences, saving lots of bytes.</p><p>However, not all cellular automata produce such easy-to-compress, repetitive patterns.</p><a class="anchor" name="rule_30"></a><h2><a href="#rule_30">Rule 30</a></h2><p>For example, Rule 30 produces the following image when starting from a single black cell:</p><p><canvas data-polyflif-src="https://res.cloudinary.com/jon/CA/r30.flif" width="1025" height="512"></canvas></p><p>This image weighs in at 215 KB as a quality 90 JPEG, and as a PNG, it is still 24 KB – compared to the 3.4 KB for the Sierpinski triangle image (Rule 22) of the same dimensions, that is quite a jump.</p><p>The pattern that rule 30 creates is intriguing: on the left it is repetitive, but on the right, it gets much more chaotic. Triangular structures emerge, but they are positioned in seemingly random ways. Interestingly, in nature there seem to be processes that lead to similar patterns, like on the shell of this <em>Conus textile</em> sea snail: </p><p><img alt="Conus textile sea snail" height="450" src="https://res.cloudinary.com/cloudinary/image/upload/w_600/sea_snail.jpg" style="margin: 0 auto;display: block" title="Conus textile sea snail" width="600" /></p><p><em>(Image Copyright (c) 2005 Richard Ling, CC-BY-SA 3.0)</em></p><a class="anchor" name="what_if_we_could_learn_the_rules"></a><h2><a href="#what_if_we_could_learn_the_rules">What if we could learn the rules?</a></h2><p>PNG performs well for repetitive images like Rule 22, because it &quot;sees&quot; the repetition and encodes it efficiently. It does not &quot;see&quot; the underlying rules of the cellular automaton though, so if those rules lead to chaotic emergent behavior, it gets into trouble. The same is true for GIF and lossless WebP, by the way.</p><p>But what if I tell you that there is an image format that can essentially just &quot;learn the rules&quot;, and compress the image very well, regardless of what those rules actually lead to?</p><p>Well, the MANIAC entropy coding of <a href="http://flif.info/" data-popup="true" rel="nofollow">FLIF</a> can do just that. It can construct a MANIAC tree that exactly corresponds to the rules of an elementary CA, making sure that each of the 8 configurations of the rules correspond to a different context for the arithmetic coder. Then the probabilities in those contexts will rapidly converge to something very close to 0 or 1, and the encoded bits will have near-zero cost.</p><p>For example, the Rule 22 image that was 3.4 KB as a PNG file, is just 83 bytes as a FLIF file. The Rule 30 image that was 24 KB as a PNG, is only 92 bytes as a FLIF.</p><p>In fact, those two CA images above (if you have javascript enabled) are actually FLIF files, decoded in your browser using a javascript <a href="https://en.wikipedia.org/wiki/Polyfill" data-popup="true" rel="nofollow">polyfill</a> called <a href="https://github.com/UprootLabs/poly-flif" data-popup="true" rel="nofollow">PolyFLIF</a>.</p><p>I obtained the smallest FLIF files with the following command-line options for the encoder:</p><p><code>flif -NX1</code></p><p>The option <code>-N</code> causes the encoder to use the non-interlaced variant of the format, so the encoding is top-to-bottom, just like the evolution of the automaton. The default is to do interlacing, which would mean that the encoder cannot &quot;see&quot; the structure since it is encoding pixels from all over the image, resulting in much worse compression. The option <code>-X1</code> is less important; it allows the arithmetic coder to use more extreme chances (1/4096 instead of the default 2/4096), bringing the &quot;near-zero&quot; cost of the bits even closer to zero.</p><a class="anchor" name="larger_and_larger_images"></a><h2><a href="#larger_and_larger_images">Larger and larger images</a></h2><p>Here’s an animated plot of the image file size of Rule 22 images with more and more rows, using different image compression formats. Note: the y-axis is logarithmic here!</p><p><video controls poster="https://res.cloudinary.com/cloudinary/video/upload/w_770,so_0,q_auto,f_auto/plot_rule22.png">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/plot_rule22.mp4" type="video/mp4">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/plot_rule22.webm" type="video/webm">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/plot_rule22.ogv" type="video/ogg">
    Plot rule22
</video></p><p>If you want an even more extreme example, <a href="http://res.cloudinary.com/jon/r30-50MP.flif" data-popup="true">here is a FLIF file</a> that contains a 50 megapixel image of the Rule 30 evolution (5000 rows). Here are the file sizes for that particular image:</p><p><span><span><br /></span></span>
<div style="margin-left: 0pt;" dir="ltr">
<table style="border: none; border-collapse: collapse; width: 100%;"><colgroup><col width="*" /><col width="*" /></colgroup>
<tbody>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">FLIF</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">2,686 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">PNG</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">2,001,971 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">Lossless WebP</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">1,967,008 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">Lossy WebP, default quality</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">14,240,092 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">Lossy WebP, lowest possible quality</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">5,985,102 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">JPEG, quality 90</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">20,300,915 bytes</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">JPEG, lowest possible quality</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px; text-align:right;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.6667px; font-family: Arial; background-color: transparent; vertical-align: baseline; white-space: pre-wrap;">4,243,508 bytes</span></p>
</td>
</tr>
</tbody>
</table>
</div>
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr">&nbsp;</p></p><p>Amazing how poorly the lossy formats perform on this image, isn’t it? Also rather interesting that PNG and lossless WebP are so close to one another – not that surprising if you know they’re based on similar entropy coding methods, but still. For me however (being the author of FLIF), the nicest thing about the above table is that FLIF beats anything else by a few orders of magnitude :).</p><p>Now, of course you shouldn’t draw too many conclusions from something like this. This is an image that is very special in the sense that it represents a best-case scenario for FLIF, while it is quite close to a worst-case scenario for the other formats. It is not that hard to come up with images that turn the tables and compress exceptionally well with, say, PNG or WebP, but compress poorly in FLIF.</p><a class="anchor" name="more_complicated_cellular_automata"></a><h2><a href="#more_complicated_cellular_automata">More complicated cellular automata</a></h2><p>FLIF can learn all elementary cellular automata, but it can also handle some more complicated ones. For example, if you allow the next state of a cell to depend not just on the current state of the cell and its neighbors, but also on the <em>previous</em> state of the cell, you get a somewhat different kind of cellular automata that can produce images like these:</p><p><canvas data-polyflif-src="https://res.cloudinary.com/jon/CA/r_tt_25.flif" width="500" height="500"></canvas>
<canvas data-polyflif-src="https://res.cloudinary.com/jon/CA/r_tt_218.flif" width="500" height="500"></canvas></p><p>Here, I initialized the top row randomly, so the FLIF files are somewhat larger: 269 bytes for the first image, 240 bytes for the second. The corresponding PNG files are 16 KB and 32 KB.</p><a class="anchor" name="totalistic_cellular_automata"></a><h2><a href="#totalistic_cellular_automata">Totalistic Cellular Automata</a></h2><p>There’s no reason to use only two colors (or states). When using more states, it becomes a bit more tricky to describe the rules concisely, since the number of different automata grows quite quickly; with just 3 states, there are 7,625 billion (3<sup>27</sup>) automata if you only look at the cell and its two neighbors, and you would need a 27-digit ternary number to describe them.</p><p>To simplify things, you can look at <a href="http://mathworld.wolfram.com/TotalisticCellularAutomaton.html" data-popup="true" rel="nofollow">totalistic cellular automata</a>, which are a subset of that huge set. In a totalistic CA, the new state depends only on the <em>sum</em> of the current states that are being considered. This forces certain symmetries. For example, the configuration 0,2,1 must result in the same new state as the configuration 1,2,0, or the configuration 1,1,1 for that matter. As a result, you need way fewer digits to specify a totalistic CA. If you have three cell states, the sum can be anything between 0 and 6, and for each of those 7 configurations, there are 3 possible new states, so 7 ternary digits are enough and there are &quot;only&quot; 2187 totalistic 3-color automata.</p><p>One of those is Rule 1599, which is my favorite totalistic CA. It looks like this:</p><p><canvas data-polyflif-src="https://res.cloudinary.com/jon/CA/r1599.flif" width="300" height="1000"></canvas></p><p>Starting from a single &quot;1&quot; cell, Rule 1599 produces this intricate pattern, which goes on for about 8000 rows and then it kind of stops, leaving only a trail of some repeating pattern, about 700 columns wide, that goes on forever. <a href="http://res.cloudinary.com/jon/CA/r1599-full.flif" data-popup="true">Here is an 899-byte FLIF file</a> that encodes the entire interesting part – it’s a 720x9000 image, so I’m not going to let your browser decode that here.</p><p>Take a look at this animated plot of the file sizes:</p><p><video controls poster="https://res.cloudinary.com/cloudinary/video/upload/w_770,so_0,q_auto,f_auto/plot_rule1599.png">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/w_770/plot_rule1599.mp4" type="video/mp4">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/w_770/plot_rule1599.webm" type="video/webm">
    <source src="https://res.cloudinary.com/cloudinary/video/upload/w_770/plot_rule1599.ogv" type="video/ogg">
    Plot rule1599
</video></p><p>In this plot, I restricted the number of MANIAC tree learning iterations to just one. You can see that initially the file size grows as the image grows, and it seems to take some time before FLIF &quot;figures out&quot; the rules of the game completely. The file size actually drops while it is learning the rules, and then it very slowly starts to go up again, encoding the extra pixels at near-zero cost. At 3000 rows, the FLIF file is still only 667 bytes, while WebP and PNG are around 140 KB and the lossy JPEG is getting close to 1 MB.</p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>One obvious conclusion from all this is <strong>don’t use lossy compression on images of Cellular Automata</strong> or in general, on highly structured artificial images with lots of fine details. That’s nothing new, but I think the examples above bring down this point quite nicely.</p><p>What’s hopefully new and interesting is that there can be huge differences between different lossless image compression formats. If the format is somehow capable of capturing the &quot;essence&quot; of the image, it might be able to compress it extremely well. For PNG (and lossless WebP), this &quot;best case&quot; scenario is <em>exact repetition</em>. For FLIF, it is harder to describe what the &quot;best cases&quot; are, but Cellular Automata certainly seem to be among them.</p><p>Finally, if all went well, this blogpost is actually the first &quot;real&quot; webpage to use FLIF images for purposes other than to demonstrate the javascript polyfill. I hope you enjoyed it!</p>]]>
      </description>
      <author />
      <pubDate>Wed, 01 Feb 2017 13:50:30 +0000</pubDate>
      <link>http://cloudinary.com/blog/compressing_cellular_automata</link>
      <guid>http://cloudinary.com/blog/compressing_cellular_automata</guid>
    </item>
    <item>
      <title>jQuery Sliders - How to Cut Slider Image Size By 96.3%</title>
      <description>
        <![CDATA[<p><img alt="Sliders" height="507" src="http://res.cloudinary.com/cloudinary/image/upload/v1481707719/sliders_blog_post.png" style="margin: 0 auto;display: block" title="Sliders" width="715" /></p><p>Have you ever noticed that home pages are slow to load? Sliders could be to blame. Many modern homepages use a slider or carousel design element to show several rotating images that provide different offers or present various aspects of the brand. A common choice for implementing these sliders is JQuery. While JQuery itself is not a performance killer, the large images displayed by the slider can be responsible for slowing down a  home page’s load time.</p><p>In this post, we’ll present the results of a test we conducted using a popular JQuery slider, <a href="http://bxslider.com/" data-popup="true" rel="nofollow">BxSlider</a>. We implemented the slider on a web page, with a width of 800px, and sampled the image file size in four different scenarios:</p>
<ol>
<li><strong>Full size images resized on the client side</strong> - This is the “worst case,” with no optimization of images at all.</li>
<li><strong>Images resized to the width of the slider</strong> - This is better, but images are resized manually, which is not convenient for responsive designs, and not optimized.</li>
<li><strong>Full size images, but with image optimization by Cloudinary</strong> - Cloudinary is a free cloud service that can optimize and modify images on the fly. In this scenario, we show how two image optimizations can reduce image size by almost 50 percent - with no resizing. </li>
<li><strong>Images dynamically resized to width of slider, with image optimization</strong> - Both resizing and optimization are done on the fly by Cloudinary. The result:  A 96.3 percent reduction in file size for the specific images used in our test.</li>
</ol>
<p>Read on to see how the four scenarios affect image size for a commonly used free JQuery slider, and how to easily go from a file size of over 6MB (in this example) to under 300KB.</p><a class="anchor" name="scenario_1_slider_with_large_images_resized_on_client_side"></a><h2><a href="#scenario_1_slider_with_large_images_resized_on_client_side">Scenario #1: Slider with Large Images Resized on Client Side</a></h2><p>Here are the sample images we chose for our BxSlider implementation. The slider shows one image at a time; here we’re showing all four.</p><p><img alt="Four Slider images" height="453" src="http://res.cloudinary.com/cloudinary/image/upload/slider_images.png" style="margin: 0 auto;display: block" title="Four Slider images" width="614" /></p><p>In this scenario, we left the original stock images as is, without reducing their size. In order to display them in our slider at 800px, images are resized on the client side. </p><p>Obviously this is a “naive” implementation, which results in huge file size. It also leaves the heavy lifting to the browser, requiring it to resize the file, which further increases page load time. Let’s take this as a worst case of non-optimized slider images.</p><p>In the following table, we show the actual image resolution (before resizing) and image file size.</p>
<table style="border: none; border-collapse: collapse"><colgroup><col width="102" /><col width="314" /><col width="*" /></colgroup>
<tbody>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Image Resolution</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File Size (KB)</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="http://res.cloudinary.com/demo/image/upload/c_thumb,w_100//balloons.jpg" alt="" width="67" height="48" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2509x1673</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1065</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/car_lady_dog.jpg" alt="" width="67" height="56" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3940x3056</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2020</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/friends.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3000x2001</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2040</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/sofa_cat.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3940x2543</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1529</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">TOTAL</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">6.7MB</span></p>
</td>
</tr>
</tbody>
</table>
<p>You wouldn’t wait for this homepage to load...</p><a class="anchor" name="scenario_2_slider_with_images_manually_resized_to_800px"></a><h2><a href="#scenario_2_slider_with_images_manually_resized_to_800px">Scenario #2: Slider with Images Manually Resized to 800px</a></h2><p>In this scenario, the original stock images were manually resized to 800px. This is an “obvious optimization,” which helps a lot in reducing image size and page load time. </p><p>However, because images were manually resized to a pre-set width (800px in our case), it’s not ideal for responsive designs. In a realistic scenario, we would need to support several viewport sizes, and then we’d have to resize each image multiple times. </p><p>Also, there are additional ways to reduce image size, as we’ll see in the following sections.</p><p>Here’s what we save via plain image resize:</p>
<p><strong id="docs-internal-guid-e2d88815-c5bc-ec22-2529-90b01255c122" style="font-weight: normal;"></strong></p>

<div style="margin-left: 0pt;" dir="ltr">
<table style="border: none; border-collapse: collapse;"><colgroup><col width="102" /><col width="186" /><col width="167" /><col width="169" /></colgroup>
<tbody>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Image Resolution</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File Size (KB)</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">% Size Reduction</span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(Resize Only)</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/balloons.jpg" alt="" width="67" height="48" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x533</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">184</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">82%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/car_lady_dog.jpg" alt="" width="67" height="56" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x620</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">118</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">94%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/friends.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x533</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">235</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">88%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/sofa_cat.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x516</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">80</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">94%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">TOTAL</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">0.6MB</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">90%</span></p>
</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>
<p>Simple resizing of the images reduced the total image size by 90 percent, so it is definitely worthwhile. </p><a class="anchor" name="scenario_3_slider_with_large_images_optimized_by_cloudinary"></a><h2><a href="#scenario_3_slider_with_large_images_optimized_by_cloudinary">Scenario #3: Slider with Large Images Optimized by Cloudinary</a></h2><p>What more can we do beyond the obvious optimization of resizing the image?</p><p>In this scenario, we’re back to using huge images with client-side resizing. We wanted to show the impact of <strong>image optimization</strong>. How much can you save on file size (and page load time) just by optimizing the images, even without reducing their size?</p><p>In a minute we’ll explain just how we optimize the images. But first let’s look at the results: The images look exactly the same, but file size compared to <a href="#scenario_1_slider_with_large_images_resized_on_client_side" rel="nofollow">Scenario 1</a> is reduced by 47 percent.</p>
<p><strong id="docs-internal-guid-e2d88815-c5c4-4379-adca-96eb6fb9b12e" style="font-weight: normal;"><br /></strong></p>

<div style="margin-left: 0pt;" dir="ltr">
<table style="border: none; border-collapse: collapse;"><colgroup><col width="102" /><col width="186" /><col width="167" /><col width="169" /></colgroup>
<tbody>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Image Resolution</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File Size (KB)</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">% Size Reduction</span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(Optimization Only)</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/balloons.jpg" alt="" width="67" height="48" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">2509x1673</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">541</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">49%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/car_lady_dog.jpg" alt="" width="67" height="56" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3940x3056</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1071</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">46%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/friends.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3000x2001</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">1099</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">46%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/sofa_cat.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3940x2543</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">930</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">39%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">TOTAL</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">3.6MB</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">49%</span></p>
</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>
<p>What’s amazing here is that the images are still huge (for example, the cute cat is a whopping 3940 pixels wide). But their file size is down from a monstrous 6.7MB in <a href="#scenario_1_slider_with_large_images_resized_on_client_side" rel="nofollow">Scenario 1</a> to a more manageable 3.6MB. We saved 47 percent on file size by optimizing the images.</p><a class="anchor" name="how_did_we_optimize_the_images"></a><h3><a href="#how_did_we_optimize_the_images">How Did We Optimize the Images?</a></h3><p>We used Cloudinary, our cloud-based service that provides end-to-end image management, including upload, storage, administration, manipulation, optimization and delivery.</p><p>With Cloudinary, you can upload images to the cloud (or let your users upload them) and automatically perform smart image manipulations without installing any software. </p><p>If you’re the one producing the images, which is probably the case if you’re building a slider for your site, you can upload the images manually using our Media Library interface or programmatically via API. Once the images are stored  in your Cloudinary account, you can perform any number of operations on them, including cropping, resizing, smart image effects, as well as various types of image optimizations. The modified images are dynamically displayed to your users and delivered via fast CDN. </p><p><strong><em>Cloudinary provides two main image optimization features, which made it possible to reduce image size by 47 percent above:</em></strong></p>
<ul>
<li><strong>Automatic quality selection</strong>: Cloudinary uses an intelligent quality and encoding algorithm to find the quality/compression level and encoding settings that produce the smallest possible file size,  without hurting visual quality. The algorithm uses perceptual metrics and heuristics to determine when an image is too compressed and does not look as good,  then stops compressing at that level. For example, Cloudinary can detect that for a JPEG image, 84 percent is the optimal quality level. This is the lowest possible JPEG quality for which the image still looks the same to a website visitor. </li>
<li><strong>Automatic format selection</strong>: Cloudinary can automatically detect a user’s browser and deliver an image in advanced file formats available for that browser: WebP in Chrome, and JPEG-XR in Internet Explorer. For other browsers, it delivers a JPEG. For many users running newer browsers, this feature can dramatically reduce file size, because WebP and JPEG-XR have much better lossless compression than regular formats like JPEG or PNG. </li>
</ul>
<p>By combining these two features, we achieved a massive reduction in file size without resizing the images at all! </p><p>Don’t worry, we’re not leaving the images like this. In <a href="#scenario_4_slider_with_images_optimized_and_auto_resized_by_cloudinary" rel="nofollow">Scenario 4</a> we’ll also resize the images, this time doing it dynamically using Cloudinary, which is much more responsive-friendly. But first a few words about how the image manipulations were done.</p><a class="anchor" name="only_one_line_of_code_per_image"></a><h3><a href="#only_one_line_of_code_per_image">Only One Line of Code (Per Image)</a></h3><p>To achieve the two image optimizations we described above, all we needed to do is the following:</p>
<ol>
<li>Upload the images to Cloudinary using the <a href="http://cloudinary.com/blog/cloud_based_media_library_management_for_web_and_mobile_applications" data-popup="true">Cloud-Based Media Library</a> or the <a href="http://cloudinary.com/documentation/image_upload_api_reference" data-popup="true">Image Upload API</a>.</li>
<li>Here is the code for bxSlider, the free slider we used in this example:</li>
</ol>
<div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><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:#369;font-weight:bold">$</span>(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">#aSlider</span><span style="color:#710">'</span></span>).bxSlider({ </span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">              <span style="color:#606">mode</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">fade</span><span style="color:#710">'</span></span>, </span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">              <span style="color:#606">captions</span>: <span style="color:#069">true</span>, </span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">              <span style="color:#606">adaptiveHeight</span>: <span style="color:#069">true</span>, </span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">              <span style="color:#606">slideWidth</span>: <span style="color:#00D">800</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>
…
<span style="color:#070;font-weight:bold">&lt;ul</span> <span style="color:#b48">id</span>=<span style="color:#F00;background-color:#FAA">”</span><span style="color:#700">aSlider</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#070;font-weight:bold">&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;li&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">http://res.cloudinary.com/demo/image/upload/q_auto,f_auto/balloons.jpg</span><span style="color:#710">&quot;</span></span> 
    <span style="color:#b48">title</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Balloons</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;/li&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;li&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">http://res.cloudinary.com/demo/image/upload/q_auto,f_auto/car_lady_dog.jpg</span><span style="color:#710">&quot;</span></span> 
    <span style="color:#b48">title</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Car, lady and dog</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;/li&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;li&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">http://res.cloudinary.com/demo/image/upload/q_auto,f_auto/friends.jpg</span><span style="color:#710">&quot;</span></span> 
    <span style="color:#b48">title</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Friends</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;/li&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;li&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">http://res.cloudinary.com/demo/image/upload/q_auto,f_auto/sofa_cat.jpg</span><span style="color:#710">&quot;</span></span> 
    <span style="color:#b48">title</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Cat on Sofa</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;/li&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/ul&gt;</span></pre></div>
</div>
</div></div>
<ol>
<li>The only difference between the “naive” implementation of the slider with full-size images stored locally (Scenario 1), and this implementation (Scenario 3), is the URLs of the images. We use a special URL that tells Cloudinary to apply the two optimizations: automatic quality (<code>q_auto</code>) and automatic image format (<code>f_auto</code>). </li>
</ol>
<p>You can generate this special URL using Cloudinary’s SDKs for all popular programming languages. The resulting URL looks like this:
<code>http://res.cloudinary.com/demo/image/upload/q_auto,f_auto/balloons.jpg</code></p><p><strong>Bottom line - image optimization alone reduced the file size by 47%</strong>: With Cloudinary’s image optimization, performed on-the-fly with a simple URL parameter, image size is reduced by 47 percent, even before we start resizing the images.</p><a class="anchor" name="scenario_4_slider_with_images_optimized_and_auto_resized_by_cloudinary"></a><h2><a href="#scenario_4_slider_with_images_optimized_and_auto_resized_by_cloudinary">Scenario #4: Slider with Images Optimized and Auto-Resized by Cloudinary</a></h2><p>In this scenario, we not only optimize the images (which, as we noted, shaves off almost 50 percent of their size), but we also use Cloudinary to <strong>dynamically resize them</strong>. </p><p>This is like <a href="##scenario_2_slider_with_images_manually_resized_to_800px" rel="nofollow">Scenario 2</a> above. But instead of manually resizing images for every viewport size, we ask Cloudinary to resize the image on-the-fly to the width of the slider, 800px, using the width parameter. In the Cloudinary back-end, the image is still stored at high resolution, but it’s delivered to the browser at a width of 800px. </p><p>In a responsive design, you could use more advanced Cloudinary options (not shown here) such as <code>c_scale</code> and <code>w_auto</code> to automatically adjust the image size to the current screen size. For more details see our <a href="http://cloudinary.com/documentation/image_transformations#automatic_responsive_images" data-popup="true">Automatic responsive images documentation</a>. Cloudinary can also perform smart cropping and resizing, while focusing on the important elements in the picture.</p><p>We are still applying the two image optimization options, <code>q_auto</code> and <code>f_auto</code>, as shown in <a href="#scenario_3_slider_with_large_images_optimized_by_cloudinary" rel="nofollow">Scenario 3</a> above. Put together with the resize, this generates the final reduction in file size:</p>
<p><strong id="docs-internal-guid-e2d88815-c609-6b91-2389-8d262b2af661" style="font-weight: normal;"><br /></strong></p>

<div style="margin-left: 0pt;" dir="ltr">
<table style="border: none; border-collapse: collapse;"><colgroup><col width="102" /><col width="186" /><col width="129" /><col width="207" /></colgroup>
<tbody>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Image Resolution</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">File Size (KB)</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">% Size Reduction</span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">(Resize + Optimization)</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/balloons.jpg" alt="" width="67" height="48" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x533</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">70</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">93%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/car_lady_dog.jpg" alt="" width="67" height="56" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x621</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">44</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">97%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/friends.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x534</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">109</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">94%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.38; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><img style="border: none; transform: rotate(0.00rad); -webkit-transform: rotate(0.00rad);" src="https://res.cloudinary.com/demo/image/upload/w_100/sofa_cat.jpg" alt="" width="70" height="49" /></span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">800x516</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">27</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">98%</span></p>
</td>
</tr>
<tr style="height: 0px;">
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">&nbsp;</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">TOTAL</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">250KB</span></p>
</td>
<td style="vertical-align: top; padding: 7px 7px 7px 7px; border: solid #000000 1px;">
<p style="line-height: 1.2; margin-top: 0pt; margin-bottom: 0pt;" dir="ltr"><span style="font-size: 14.666666666666666px; font-family: Arial; color: #000000; background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">96.3%</span></p>
</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>
<p>This is where we want to be! All four images, still look the same, but they are down to a fraction of their original size. </p><a class="anchor" name="the_code"></a><h3><a href="#the_code">The Code</a></h3><p>The BxSlider code is exactly the same, with a small change to the image URLs:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">&lt;!--bxSlider CSS file--&gt;</span> 
<span style="color:#070;font-weight:bold">&lt;link</span> <span style="color:#b48">href</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">/js/vendor/jquery.bxslider.min.css</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">rel</span>=<span style="color:#F00;background-color:#FAA">”</span><span style="color:#700">stylesheet</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#070;font-weight:bold">/&gt;</span>
…
<span style="color:#070;font-weight:bold">&lt;ul</span> <span style="color:#b48">id</span>=<span style="color:#F00;background-color:#FAA">”</span><span style="color:#700">aSlider</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#070;font-weight:bold">&gt;</span>
 <span style="color:#070;font-weight:bold">&lt;li&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">http://res.cloudinary.com/demo/image/upload/q_auto,f_auto,w_800/balloons.jpg</span><span style="color:#710">&quot;</span></span> 
    <span style="color:#b48">title</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Balloons</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;/li&gt;</span>
…
<span style="color:#070;font-weight:bold">&lt;/ul&gt;</span></pre></div>
</div>
</div></div><p>All we did was to add <code>w_800</code> to the URL, which resizes the image to a width of 800px while retaining the aspect ratio. Combined with the image optimizations, this reduced file size by the full 96.3 percent, compared to only 90 percent for just a manual resize without optimization (Scenario 2). And to top it off, there was no manual labor involved.</p><p>Here is the URL that achieves this, which you can generate in the programming language of choice (using one of our SDKs):
<code>http://res.cloudinary.com/demo/image/upload/q_auto,f_auto,w_800/balloons.jpg</code></p><p><strong>Bottom line - Dynamic resize + optimization sliced off 96.3 percent of image size</strong>: Here we combined three image manipulations: resize, automatic quality selection and automatic format selection, which together reduced image size by 96.3 percent compared to the huge stock images from Scenario 1. All of this was done dynamically by Cloudinary and delivered to users on-the-fly. You can change parameters, add or remove image manipulations at any time for any number of images, and users will immediately see the change.</p><a class="anchor" name="addendum_automatic_responsive_breakpoints"></a><h3><a href="#addendum_automatic_responsive_breakpoints">Addendum: Automatic Responsive Breakpoints</a></h3><p>If you’re working on a responsive slider, leveraging automatic responsive breakpoints might come in handy. When building any responsive design, there’s a need to decide which image resolutions to select and how many different image versions to include in your responsive website. These are called responsive breakpoints or responsive image breakpoints.</p><p>To perfectly balance the number of image versions for your responsive website, you need to find the correct number of breakpoints according to the file size steps that you define. You can (theoretically) generate images for all possible width values and then select only those that provide a file size reduction that is really significant. However this is quite difficult to do in practice.</p><p>Cloudinary analyzed the behavior of compression mechanisms for various image formats (mainly JPEG, PNG and WebP) and created an algorithm that can intelligently identify the optimal image breakpoints and give you the best tradeoff between file size and bandwidth (the more image versions, the more bandwidth is consumed).</p><p>Check out our open source tool <a href="http://www.responsivebreakpoints.com/" data-popup="true" rel="nofollow">Responsive Breakpoints Generator</a> to automatically determine the optimal image breakpoints for your responsive design.</p><a class="anchor" name="summary"></a><h2><a href="#summary">Summary</a></h2><p>Image sliders, which are often but not always based on JQuery, are a big contributor to the load time of home pages and other media-heavy web pages. Because sliders use large images, they are a prime candidate for image optimization. </p><p>In this post, we showed two strategies for reducing image size: </p>
<ul>
<li>Simple resizing, a very effective tactic that can reduce image size by as much as 90% compared to original stock images</li>
<li>Finding the optimal file format and the lowest quality level that won’t hurt the visual quality of the images - in our test, this reduced image size by an additional 47% </li>
</ul>
<p>In this blog, we showed how to do both of these easily in Cloudinary, a cloud-based service that provides end-to-end image management, including upload, storage, administration, manipulation, optimization and delivery. Cloudinary can dynamically resize images, even in multiple sizes for responsive designs, and can automatically switch an image to the file format and quality level that will provide the lowest possible file size. In our test on a free JQuery slider, this reduced image size by a whopping 96.3% compared to the original stock images.</p><p>Now you can try this out with your own images. If you don&#39;t already have a Cloudinary account, <a href="http://cloudinary.com/signup" data-popup="true">sign up</a> for the free plan.</p>]]>
      </description>
      <author />
      <pubDate>Wed, 25 Jan 2017 12:53:06 +0000</pubDate>
      <link>http://cloudinary.com/blog/jquery_sliders_how_to_cut_slider_image_size_by_99_96</link>
      <guid>http://cloudinary.com/blog/jquery_sliders_how_to_cut_slider_image_size_by_99_96</guid>
    </item>
    <item>
      <title>New Angular SDK for image management - More than meets the eye</title>
      <description>
        <![CDATA[<p><img alt="Cloudinary Angular SDK for image management" height="1224" src="https://res.cloudinary.com/cloudinary/image/upload/v1483889055/blog/angular_sdk.png" style="margin: 0 auto;display: block" title="Cloudinary Angular SDK for image management" width="1540" /></p><p><a href="http://www.imdb.com/title/tt0094142/quotes?item=qt3010733" data-popup="true" rel="nofollow">The night was moist</a>. Angular2 had just been released and developers all over the world were asking for an integrated image management solution.</p><p>Cloudinary heeded the call and is proud to present the new Angular2 SDK, providing directives for displaying and transforming images and video with an API.</p><a class="anchor" name="wait_what_s_cloudinary"></a><h2><a href="#wait_what_s_cloudinary">Wait, what&#39;s Cloudinary?</a></h2><p>Cloudinary is an end-to-end image and video management solution for your website and mobile apps. Cloudinary covers everything from media uploads and storage to manipulations, optimizations, and delivery.</p><p>You can easily upload images and video to the cloud and automatically perform smart manipulations without installing any complex software. You can also integrate a Facebook or Twitter profile image in a snap, in any dimension and style to match your website’s graphics requirements. All your media files are seamlessly delivered through a fast CDN, optimized and using industry best practices.</p><p>For more information visit our <a href="https://cloudinary.com/features" data-popup="true">Features Page</a>.</p><a class="anchor" name="why_do_i_need_an_sdk"></a><h2><a href="#why_do_i_need_an_sdk">Why do I need an SDK?</a></h2><p>Cloudinary provides RESTful APIs that can be easily integrated with any Web development framework, but the new Angular SDK makes it easier to consume Cloudinary&#39;s service in your Angular2 app.</p><p>Let’s see how this is done by transforming Angular’s logo:</p><p><div class="example multi_code "><a class="anchor" name="angular_logo_transformation"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="https://res.cloudinary.com/demo/image/upload/c_crop,e_pixelate:8,g_north,h_0.5,l_angular_logo,w_1.0/fl_layer_apply,g_north/c_fit,w_180/angular_logo" 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">c_crop,e_pixelate:8,g_north,h_0.5,l_angular_logo,w_1.0/fl_layer_apply,g_north/c_fit,w_180/</span><span class="public_id">angular_logo</span></a></span></code></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">angular_logo</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:secure</span>=&gt;<span style="color:#069">true</span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate:8</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">:height</span>=&gt;<span style="color:#60E">0.5</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">angular_logo</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#60E">1.0</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">crop</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">north</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#A60">:width</span>=&gt;<span style="color:#00D">180</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">fit</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">angular_logo</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">secure</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#069">true</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">effect</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">pixelate:8</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">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">height</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#60E">0.5</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">angular_logo</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:#60E">1.0</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">crop</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">north</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">width</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">180</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">fit</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">angular_logo</span><span style="color:#710">&quot;</span></span>).image(secure=<span style="color:#069">True</span>, transformation=[
  {<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">effect</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">pixelate:8</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">height</span><span style="color:#710">&quot;</span></span>: <span style="color:#60E">0.5</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">angular_logo</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:#60E">1.0</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">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">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">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">width</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">180</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">fit</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">angular_logo</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</span>, <span style="color:#606">transformation</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">pixelate:8</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">height</span>: <span style="color:#60E">0.5</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">angular_logo</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.0</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">crop</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">north</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">180</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>}
  ]})</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()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate:8</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">north</span><span style="color:#710">&quot;</span></span>).height(<span style="color:#60E">0.5</span>).overlay(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo</span><span style="color:#710">&quot;</span></span>).width(<span style="color:#60E">1.0</span>).crop(<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>).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">north</span><span style="color:#710">&quot;</span></span>).chain()
  .width(<span style="color:#00D">180</span>).crop(<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>)).secure(<span style="color:#069">true</span>).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo</span><span style="color:#710">&quot;</span></span>)</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">angular_logo</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">secure</span>: <span style="color:#069">true</span>, <span style="color:#606">transformation</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">pixelate:8</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">height</span>: <span style="color:#60E">0.5</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">angular_logo</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#60E">1.0</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">crop</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">north</span><span style="color:#710">&quot;</span></span>},
  {<span style="color:#606">width</span>: <span style="color:#00D">180</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>}
  ]})</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(new Transformation()
  .Effect(&quot;pixelate:8&quot;).Gravity(&quot;north&quot;).Height(0.5).Overlay(&quot;angular_logo&quot;).Width(1.0).Crop(&quot;crop&quot;).Chain()
  .Flags(&quot;layer_apply&quot;).Gravity(&quot;north&quot;).Chain()
  .Width(180).Crop(&quot;fit&quot;)).Secure(true).BuildImageTag(&quot;angular_logo&quot;)</pre></div>
</div>
</div></div></div></div><a href="https://res.cloudinary.com/demo/image/upload/c_crop,e_pixelate:8,g_north,h_0.5,l_angular_logo,w_1.0/fl_layer_apply,g_north/c_fit,w_180/angular_logo" data-popup="true"><img alt="Angular logo transformation" height="180" src="https://res.cloudinary.com/demo/image/upload/c_crop,e_pixelate:8,g_north,h_0.5,l_angular_logo,w_1.0/fl_layer_apply,g_north/c_fit,w_180/angular_logo" style="margin: 0 auto;display: block" title="Angular logo transformation" width="180" /></a></p><p><em>(<a href="https://angular.io/presskit.html" data-popup="true" rel="nofollow">Angular logo</a> is released under <a href="https://creativecommons.org/licenses/by/4.0/" data-popup="true" rel="nofollow">CC BY 4.0</a>)</em></p><p>The above image was generated by overlaying the Angular logo onto itself, cropping the overlay and pixelating its top, then cropping the result to be 180px wide.</p><p>The same transformation can be achieved in your Angular2 app using the following directives:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>    &lt;cl-image secure=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></span> <span style="color:#080;font-weight:bold">public</span>-id=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo</span><span style="color:#710">&quot;</span></span> width=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">180</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">fit</span><span style="color:#710">&quot;</span></span>&gt;
        &lt;cl-transformation overlay=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo</span><span style="color:#710">&quot;</span></span> width=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1.0</span><span style="color:#710">&quot;</span></span> height=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">0.5</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">crop</span><span style="color:#710">&quot;</span></span> effect=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">pixelate:8</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">north</span><span style="color:#710">&quot;</span></span>&gt;&lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">cl-transformation&gt;</span></span>
<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#808">        &lt;cl-transformation flags=&quot;layer_apply&quot; gravity=&quot;north&quot;&gt;&lt;</span><span style="color:#404">/</span></span>cl-transformation&gt;
    &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">cl-image&gt;</span></span></pre></div>
</div>
</div></div><p>Additional transformation examples can be found in the <a href="http://cloudinary.com/documentation/jquery_image_manipulation" data-popup="true">jQuery image manipulation guide</a> and the <a href="http://cloudinary.com/documentation/image_transformation_reference" data-popup="true">complete image transformation reference</a></p><p>The same applies to videos:</p><p><video controls="controls" height="332" poster="https://cloudinary-res.cloudinary.com/video/upload/g_north,l_text:arial_30:Cloudinary features,y_8,co_red/w_1000/manipulation_video.jpg" preload="none" style="margin: 0 auto;display: block" width="1000"><source src="https://cloudinary-res.cloudinary.com/video/upload/g_north,l_text:arial_30:Cloudinary features,y_8,co_red/w_1000/manipulation_video.webm" type="video/webm" /><source src="https://cloudinary-res.cloudinary.com/video/upload/g_north,l_text:arial_30:Cloudinary features,y_8,co_red/w_1000/manipulation_video.mp4" type="video/mp4" /><source src="https://cloudinary-res.cloudinary.com/video/upload/g_north,l_text:arial_30:Cloudinary features,y_8,co_red/w_1000/manipulation_video.ogv" type="video/ogg" /></video></p><p>The link to this video is </p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>https:<span style="color:#777">//res.cloudinary.com/cloudinary/video/upload/g_north,l_text:arial_30:Cloudinary%20features,y_8,co_red/w_1000/manipulation_video.mp4</span></pre></div>
</div>
</div></div><p>This can be achieved using the Angular SDK with the following directives:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>&lt;cl-video <span style="color:#080;font-weight:bold">public</span>-id=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">manipulation_video</span><span style="color:#710">&quot;</span></span>
cloud-name=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cloudinary</span><span style="color:#710">&quot;</span></span> controls=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></span> 
preload=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">none</span><span style="color:#710">&quot;</span></span> autoplay=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></span>
width=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">1000</span><span style="color:#710">&quot;</span></span> secure=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></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">manipulation-video</span><span style="color:#710">&quot;</span></span>&gt;
   &lt;cl-transformation overlay=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">text:arial_30:Cloudinary%20features</span><span style="color:#710">&quot;</span></span> 
        color=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">red</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">north</span><span style="color:#710">&quot;</span></span> y=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">8</span><span style="color:#710">&quot;</span></span>&gt;
   &lt;<span style="background-color:hsla(300,100%,50%,0.06)"><span style="color:#404">/</span><span style="color:#808">cl-transformation&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>cl-video&gt;</pre></div>
</div>
</div></div><a class="anchor" name="how_do_i_start_using_the_sdk"></a><h2><a href="#how_do_i_start_using_the_sdk">How do I start using the SDK?</a></h2><a class="anchor" name="installation"></a><h3><a href="#installation">Installation</a></h3><p>The SDK can be installed via Node Package Manager by executing the following command in your application&#39;s root folder</p><p><code>npm install @cloudinary/angular --save</code></p><p>Or if you’re using <a href="https://yarnpkg.com/" data-popup="true" rel="nofollow">yarn</a>:</p><p><code>yarn add @cloudinary/angular</code></p><a class="anchor" name="cloudinary_module_configuration"></a><h3><a href="#cloudinary_module_configuration">Cloudinary module configuration</a></h3><p>The SDK is based on <a href="https://cloudinary.com/blog/painless_image_and_video_manipulation_with_javascript" data-popup="true">Cloudinary&#39;s Javascript module</a>, however the two are decoupled. 
The <code>Cloudinary</code> module is a configurable service to which you provide your choice of our JS module.</p><p>See below for an example Cloudinary configuration in the application module definition:</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> { NgModule } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@angular/core</span><span style="color:#710">'</span></span>;
...
<span style="color:#080;font-weight:bold">import</span> { CloudinaryModule, CloudinaryConfiguration, provideCloudinary } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@cloudinary/angular</span><span style="color:#710">'</span></span>;

<span style="color:#F00;background-color:#FAA">@</span>NgModule({
    <span style="color:#606">imports</span>: [
        CloudinaryModule
    ],
    <span style="color:#606">providers</span>: [
        provideCloudinary(require(<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:#606">cloud_name</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">your_cloud_name</span><span style="color:#710">'</span></span> } as CloudinaryConfiguration)
    ],
    <span style="color:#606">bootstrap</span>: [...]
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> AppModule { }</pre></div>
</div>
</div></div><p>If you are using <a href="https://angular.io/docs/ts/latest/cookbook/aot-compiler.html" data-popup="true" rel="nofollow">Angular AOT</a> you need to configure Cloudinary a bit differently:</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> { NgModule } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@angular/core</span><span style="color:#710">'</span></span>;
...
<span style="color:#080;font-weight:bold">import</span> { CloudinaryModule } from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">@cloudinary/angular</span><span style="color:#710">'</span></span>;
<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/cloudinary-core-shrinkwrap</span><span style="color:#710">'</span></span>;

const cloudinaryLib = {
  <span style="color:#606">Cloudinary</span>: Cloudinary
}

<span style="color:#F00;background-color:#FAA">@</span>NgModule({
    <span style="color:#606">imports</span>: [
    CloudinaryModule.forRoot(cloudinaryLib, {
      <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">your_cloud_name</span><span style="color:#710">'</span></span>
    })
    ],
    <span style="color:#606">bootstrap</span>: [...]
})
<span style="color:#080;font-weight:bold">export</span> <span style="color:#080;font-weight:bold">class</span> AppModule { }</pre></div>
</div>
</div></div><a class="anchor" name="cloudinary_directives"></a><h3><a href="#cloudinary_directives">Cloudinary directives</a></h3><p>The <code>Cloudinary</code> module provides a component and several directives for: </p>
<ul>
<li>Creating new image and video tags and controlling the underlying chained transformations</li>
<li>Enhancing native HTML elements with Cloudinary image management capabilities</li>
</ul>
<h5>Creating image tags with cl-image &amp; cl-transformation</h5><p>The <code>cl-image</code> component generates an image tag with the requested transformation, type, and format. 
The image tag can contain optional <code>cl-transformation</code> elements that will be used for <a href="https://cloudinary.com/documentation/image_transformations#chained_transformations" data-popup="true">chained transformations</a>.</p><p>The following example demonstrates a chained transformation with several components applied to a single image</p><p><div class="example multi_code "><a class="anchor" name="angular_logo_chained_transformations"></a><div class="code_sample framework_sample active" data-framework="url"><div class="framework_name">URL:</div><div class="code-holder"><code class="code_inner"><span class="url"><a href="http://res.cloudinary.com/demo/image/upload/c_fill,e_sepia,h_150,w_150/co_rgb:EECCAA,g_south,l_text:arial_20:Angular,y_20/a_20/angular_logo.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">c_fill,e_sepia,h_150,w_150/co_rgb:EECCAA,g_south,l_text:arial_20:Angular,y_20/a_20/</span><span class="public_id">angular_logo.jpg</span></a></span></code></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">angular_logo.jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:transformation</span>=&gt;[
  {<span style="color:#A60">:effect</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sepia</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:height</span>=&gt;<span style="color:#00D">150</span>, <span style="color:#A60">:width</span>=&gt;<span style="color:#00D">150</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">:color</span>=&gt;<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#EECCAA</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">south</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">text:arial_20:Angular</span><span style="color:#710">&quot;</span></span>, <span style="color:#A60">:y</span>=&gt;<span style="color:#00D">20</span>},
  {<span style="color:#A60">:angle</span>=&gt;<span style="color:#00D">20</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">angular_logo.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">effect</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">sepia</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>=&gt;<span style="color:#00D">150</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">150</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">color</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">#EECCAA</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">south</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">text:arial_20:Angular</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">y</span><span style="color:#710">&quot;</span></span>=&gt;<span style="color:#00D">20</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">20</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">angular_logo.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">effect</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">sepia</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">150</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">150</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">color</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">#EECCAA</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">south</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">text:arial_20:Angular</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">y</span><span style="color:#710">&quot;</span></span>: <span style="color:#00D">20</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">20</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">angular_logo.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">sepia</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">height</span>: <span style="color:#00D">150</span>, <span style="color:#606">width</span>: <span style="color:#00D">150</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">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#EECCAA</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">south</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">text:arial_20:Angular</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">y</span>: <span style="color:#00D">20</span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">20</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()
  .effect(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sepia</span><span style="color:#710">&quot;</span></span>).height(<span style="color:#00D">150</span>).width(<span style="color:#00D">150</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()
  .color(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#EECCAA</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">south</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">text:arial_20:Angular</span><span style="color:#710">&quot;</span></span>).y(<span style="color:#00D">20</span>).chain()
  .angle(<span style="color:#00D">20</span>)).imageTag(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo.jpg</span><span style="color:#710">&quot;</span></span>)</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">angular_logo.jpg</span><span style="color:#710">&quot;</span></span>, {<span style="color:#606">transformation</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">sepia</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">height</span>: <span style="color:#00D">150</span>, <span style="color:#606">width</span>: <span style="color:#00D">150</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">color</span>: <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#EECCAA</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">south</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">text:arial_20:Angular</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">y</span>: <span style="color:#00D">20</span>},
  {<span style="color:#606">angle</span>: <span style="color:#00D">20</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(new Transformation()
  .Effect(&quot;sepia&quot;).Height(150).Width(150).Crop(&quot;fill&quot;).Chain()
  .Color(&quot;#EECCAA&quot;).Gravity(&quot;south&quot;).Overlay(&quot;text:arial_20:Angular&quot;).Y(20).Chain()
  .Angle(20)).BuildImageTag(&quot;angular_logo.jpg&quot;)</pre></div>
</div>
</div></div></div></div><a href="http://res.cloudinary.com/demo/image/upload/c_fill,e_sepia,h_150,w_150/co_rgb:EECCAA,g_south,l_text:arial_20:Angular,y_20/a_20/angular_logo.jpg" data-popup="true"><img alt="Angular logo chained transformations" height="192" src="http://res.cloudinary.com/demo/image/upload/c_fill,e_sepia,h_150,w_150/co_rgb:EECCAA,g_south,l_text:arial_20:Angular,y_20/a_20/angular_logo.jpg" style="margin: 0 auto;display: block" title="Angular logo chained transformations" width="192" /></a></p><p>It starts by cropping the image to 150x150 pixels and adds a sepia effect.
Then it adds a text overlay with the word <code>Angular</code> with a specific font type, font size and color, and positions the text at the bottom. Finally, it rotates the result by 20 degrees:</p><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">angular_logo</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">logo</span><span style="color:#710">&quot;</span></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">20</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">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">height</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">150</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">150</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:#b48">effect</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">sepia</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">text:arial_20:Angular</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">color</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">#EECCAA</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">south</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">y</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">20</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><p>This will be compiled by Angular to:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;img</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">logo</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">_ngcontent_ovt_3</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#710">&quot;</span></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">angular_logo</span><span style="color:#710">&quot;</span></span> 
  <span style="color:#b48">ng_reflect_public_id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">angular_logo</span><span style="color:#710">&quot;</span></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">http://res.cloudinary.com/eitanpeer/image/upload/c_fill,e_sepia,h_150,w_150/co_rgb:EECCAA,g_south,l_text:arial_20:Angular,y_20/a_20/angular_logo.jpg</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span></pre></div>
</div>
</div></div><h5>Creating video tags with cl-video and cl-transformation</h5><p>The <code>cl-video</code> component generates a <code>&lt;video&gt;</code> tag with the requested transformation, type, and format. The component automatically generates video <code>&lt;source&gt;</code> URLs for all formats supported by web browsers (<code>webm</code>, <code>mp4</code> and <code>ogv</code>) as a fallback in case the user&#39;s browser doesn&#39;t support one of them. </p><p>The video tag can contain optional <code>cl-transformation</code> elements that will be used for <a href="https://cloudinary.com/documentation/image_transformations#chained_transformations" data-popup="true">chained transformations</a>.</p><p>The following example demonstrates creating a video tag with a single transformation.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;cl-video</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">manipulation_video</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">cloud_name</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">cloudinary</span><span style="color:#710">&quot;</span></span> 
   <span style="color:#b48">controls</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">preload</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">none</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">925</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:#b48">autoplay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</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">manipulation-video</span><span style="color:#710">&quot;</span></span>
   <span style="color:#b48">fallback-content</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">Your browser does not support HTML5 video tags</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">overlay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">text:arial_20:Cloudinary%20features</span><span style="color:#710">&quot;</span></span> 
   <span style="color:#b48">color</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">red</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">north</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">y</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">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;/cl-transformation&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/cl-video&gt;</span></pre></div>
</div>
</div></div><p>The component automatically adds the source elements and a poster. The example above is compiled by Angular to:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>
<span style="color:#070;font-weight:bold">&lt;video</span> <span style="color:#b48">_ngcontent-odx-3</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">autoplay</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</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">manipulation-video</span><span style="color:#710">&quot;</span></span> 
   <span style="color:#b48">controls</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">true</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">preload</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">none</span><span style="color:#710">&quot;</span></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">manipulation_video</span><span style="color:#710">&quot;</span></span> 
   <span style="color:#b48">ng-reflect-public-id</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">manipulation_video</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">925</span><span style="color:#710">&quot;</span></span>
   <span style="color:#b48">poster</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">http://res.cloudinary.com/cloudinary/video/upload/co_red,g_north,l_text:arial_20:Cloudinary%20features,y_12/c_scale,w_925/manipulation_video.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;source</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">http://res.cloudinary.com/cloudinary/video/upload/co_red,g_north,l_text:arial_20:Cloudinary%20features,y_12/c_scale,w_925/manipulation_video.webm</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">video/webm</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;source</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">http://res.cloudinary.com/cloudinary/video/upload/co_red,g_north,l_text:arial_20:Cloudinary%20features,y_12/c_scale,w_925/manipulation_video.mp4</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">video/mp4</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;source</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">http://res.cloudinary.com/cloudinary/video/upload/co_red,g_north,l_text:arial_20:Cloudinary%20features,y_12/c_scale,w_925/manipulation_video.ogv</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">video/ogg</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
Your browser does not support HTML5 video tags
<span style="color:#070;font-weight:bold">&lt;/video&gt;</span></pre></div>
</div>
</div></div><h5>Attribute directives for enhancing HTML elements - clSrc, clHref, clSrcset</h5><p>The <code>clSrc</code>, <code>clHref</code>, and <code>clSrcset</code> directives use the element attributes to generate image URLs in Cloudinary.</p><p>The following example demonstrates an image thumbnail that displays the full size image when clicked, displaying the full size image optimized with auto quality as a transformation:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;a</span> <span style="color:#b48">clHref</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">photo.public_id</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#F00;background-color:#FAA">}</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">jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">target</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">_blank</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</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:#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</span> <span style="color:#b48">publicId</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">photo.public_id</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#F00;background-color:#FAA">}</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">thumbnail inline</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">150</span><span style="color:#710">&quot;</span></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">150</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">fit</span><span style="color:#710">&quot;</span></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">80</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">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>
<span style="color:#070;font-weight:bold">&lt;/a&gt;</span></pre></div>
</div>
</div></div><a class="anchor" name="is_this_an_upgrade_of_the_previous_cloudinary_angularjs_sdk"></a><h2><a href="#is_this_an_upgrade_of_the_previous_cloudinary_angularjs_sdk">Is this an upgrade of the previous Cloudinary AngularJS SDK?</a></h2><p>No. Since Angular itself is a rewrite of AngularJS, the new Angluar SDK is not backwards compatible with Cloudinary’s AngularJS (A.K.A Angular 1) SDK.</p><p>However, we are happy to share some tips regarding  the migration path for upgrading your previous AngularJS app using Cloudinary’s SDK to the new one.</p><a class="anchor" name="migration_path"></a><h3><a href="#migration_path">Migration path</a></h3><p>We’ve tried to keep the APIs as close as possible to the original names. We’ve made some changes to conform to Angular’s new style guide.</p>
<ul>
<li><code>clHref</code>, <code>clSrc</code>, <code>clSrcset</code> - 
These directives have been renamed from <code>cl-href</code>, <code>cl-src</code>, <code>cl-srcset</code> to be consistent with <a href="https://angular.io/styleguide#!#02-06" data-popup="true" rel="nofollow">Angular&#39;s directive selector naming guidelines</a></li>
<li><code>cl-video</code> -  has been added to the new SDK:</li>
</ul>
<p><strong>Angular 1 SDK</strong>:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre> <span style="color:#070;font-weight:bold">&lt;a</span> <span style="color:#b48">cl-href</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{{photo.public_id}}</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">jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">target</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">_blank</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span></pre></div>
</div>
</div></div><p><strong>Angular 2 SDK</strong>:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;a</span> <span style="color:#b48">clHref</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">{{photo.public_id}}</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">jpg</span><span style="color:#710">&quot;</span></span> <span style="color:#b48">target</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">_blank</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span></pre></div>
</div>
</div></div><a class="anchor" name="can_you_share_tips_and_tricks_from_the_upgrade"></a><h3><a href="#can_you_share_tips_and_tricks_from_the_upgrade">Can you share tips and tricks from the upgrade ?</a></h3><p>In addition to the process of upgrading your Cloudinary SDK code, you may want to consider the following as you migrate your  own Angular 1 app to the new version:</p>
<ul>
<li>Use the <a href="https://angular.io/docs/ts/latest/cookbook/a1-a2-quick-reference.html" data-popup="true" rel="nofollow">Angular 1 to 2 quick reference</a> for updating your application&#39;s Angular syntax. Following it will get most of your application ready for Angular2.</li>
<li>Pay special attention to the new <a href="https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding" data-popup="true" rel="nofollow">binding syntax</a>. Read it carefully, understand the new mental model and take note of the different binding syntaxes for the different data directions, i.e. 

<ul>
<li>One-way from data source to view target. There are 3 different styles for this type of binding:

<ul>
<li><code>{{expression}}</code> (known as &quot;Interpolation&quot;)</li>
<li><code>[target] = &quot;expression&quot;</code> (known as &quot;Property attribute&quot;)</li>
<li><code>bind-target = &quot;expression&quot;</code></li>
</ul></li>
<li>One-way from view target to data source. There are 2 different styles for this type of binding:

<ul>
<li><code>(target) = &quot;statement&quot;</code></li>
<li><code>on-target = &quot;statement&quot;</code></li>
</ul></li>
<li>Two-way. There are 2 different styles for this type of binding:

<ul>
<li><code>[(target)] = &quot;expression&quot;</code></li>
<li><code>bindon-target = &quot;expression&quot;</code></li>
</ul></li>
</ul></li>
<li>A lot of content has already been created for the Angular release candidates. Some do not apply to the final released version. Pay attention to the Angular versions in question and dates in the blog posts and StackOverflow answers you read.</li>
<li>Check out this <a href="https://github.com/AngularClass/awesome-angular2" data-popup="true" rel="nofollow">curated list of awesome Angular 2 resources by @AngularClass</a>. It has a lot of references for deep diving into Angular’s new architecture and implementation.</li>
</ul>
<a class="anchor" name="anything_else"></a><h2><a href="#anything_else">Anything else?</a></h2><p>Yes. I&#39;m glad you asked.</p><p>We’ve created sample projects for the SDK, demonstrating different capabilities and options.
In addition, we’ve created a plunker so you can get up and running in no time, without any setup!</p><p>The sample projects have the same functionality - a photo list displaying a list of images that respond to a predefined tag, and an upload page for adding images to the list.</p><p>The projects differ in their bundling solutions and image upload mechanisms: </p><a class="anchor" name="_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_data_popup_true_rel_nofollow_photo_album_a"></a><h3><a href="#_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_data_popup_true_rel_nofollow_photo_album_a"><a href="https://github.com/cloudinary/cloudinary_angular/tree/angular_next/samples/photo_album" data-popup="true" rel="nofollow">Photo Album</a></a></h3><p>This project uses: </p>
<ul>
<li><a href="https://github.com/valor-software/ng2-file-upload" data-popup="true" rel="nofollow">ng2-file-upload</a> for uploading files using an open source file uploader</li>
<li><a href="https://webpack.github.io/" data-popup="true" rel="nofollow">Webpack</a> for bundling and serving the application</li>
</ul>
<a class="anchor" name="_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_with_jquery_data_popup_true_rel_nofollow_photo_album_with_jquery_a"></a><h3><a href="#_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_with_jquery_data_popup_true_rel_nofollow_photo_album_with_jquery_a"><a href="https://github.com/cloudinary/cloudinary_angular/tree/angular_next/samples/photo_album_with_jquery" data-popup="true" rel="nofollow">Photo Album with jQuery</a></a></h3><p>This project uses: </p>
<ul>
<li><a href="http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud#direct_uploading_from_the_browser_using_jquery" data-popup="true">Cloudinary&#39;s jQuery plugin</a> for uploading files using jQuery and blueimp</li>
<li><a href="https://github.com/systemjs/systemjs" data-popup="true" rel="nofollow">SystemJS</a> for bundling the application </li>
<li><a href="https://github.com/johnpapa/lite-server" data-popup="true" rel="nofollow">lite-server</a> as the web server serving the application</li>
</ul>
<a class="anchor" name="_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_aot_data_popup_true_rel_nofollow_photo_album_aot_application_a"></a><h3><a href="#_a_href_https_github_com_cloudinary_cloudinary_angular_tree_angular_next_samples_photo_album_aot_data_popup_true_rel_nofollow_photo_album_aot_application_a"><a href="https://github.com/cloudinary/cloudinary_angular/tree/angular_next/samples/photo_album_aot" data-popup="true" rel="nofollow">Photo Album AOT application</a></a></h3><p>This project demonstrates how the Cloudinary SDK could be used in an Angular application created by Angular’s <a href="https://angular.io/docs/ts/latest/cookbook/aot-compiler.html" data-popup="true" rel="nofollow">Ahead of Time compiler</a>. It uses: </p>
<ul>
<li><a href="https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli" data-popup="true" rel="nofollow">Angular’s template  compiler</a> for ahead-of-time compilation of the application</li>
<li><a href="https://github.com/rollup/rollup" data-popup="true" rel="nofollow">Rollup</a> for bundling the application </li>
<li><a href="https://github.com/johnpapa/lite-server" data-popup="true" rel="nofollow">lite-server</a> as the web server serving the application</li>
</ul>
<a class="anchor" name="plunker"></a><h3><a href="#plunker">Plunker</a></h3><p>The <a href="https://embed.plnkr.co/e4GuRg" data-popup="true" rel="nofollow">plunker code sample</a> is configured to use Cloudinary’s <code>demo</code> cloud, and demonstrates usage of <code>&lt;cl-image&gt;</code> tags. Feel free to fork it and experiment with your own cloud credentials.</p>
<iframe style="border: 1px solid #999;width: 100%; height: 500px"
        src="https://embed.plnkr.co/e4GuRg" frameborder="0"
        allowfullscreen="allowfullscreen">
  Loading plunk...
</iframe>
<a class="anchor" name="summary"></a><h2><a href="#summary">Summary</a></h2><p><a href="http://www.imdb.com/title/tt0094142/quotes?item=qt3010733" data-popup="true" rel="nofollow">Whether the night was moist, humid, or sultry</a> the main thing here is that you can easily integrate Cloudinary into your Angular application with the new SDK.</p><p>These are the basics:</p>
<ul>
<li><p>Use <code>cl-image</code> and <code>cl-transformation</code> for expressively serving images from your Cloudinary account.</p></li>
<li><p>Use <code>cl-video</code> and <code>cl-transformation</code> for expressively serving videos from your Cloudinary account, setting up multiple sources for different browsers automatically.</p></li>
<li><p>Use <code>clSrc</code>, <code>clHref</code> or <code>clSrcset</code> for enhancing native HTML elements to serve images from your Cloudinary account.</p></li>
</ul>
<p>For more detail on all available Cloudinary Angular directives and components, see <a href="https://github.com/cloudinary/cloudinary_angular/tree/angular_next" data-popup="true" rel="nofollow">the SDK documentation</a></p>]]>
      </description>
      <author />
      <pubDate>Wed, 18 Jan 2017 14:04:05 +0000</pubDate>
      <link>http://cloudinary.com/blog/new_angular_sdk_for_image_management_more_than_meets_the_eye</link>
      <guid>http://cloudinary.com/blog/new_angular_sdk_for_image_management_more_than_meets_the_eye</guid>
    </item>
    <item>
      <title>How to develop a React library</title>
      <description>
        <![CDATA[<p><img alt="How to develop a React library" height="467" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/react_library_post.jpg" style="margin: 0 auto;display: block" title="How to develop a React library" width="700" /></p><p>Developing a library requires a different approach from developing an application. You must consider the use of the library in someone else’s application and design for it. React is well suited for this purpose. And if the library you are creating is an adapter to another library, you can dynamically generate the component&#39;s properties definition to ensure they are forward compatible. There is however more than one way to achieve the same goal, with some conventions to follow and others to cautiously not follow. In particular, I chose to use the context function even though it is an experimental feature because it is useful when you don’t know, or can’t dictate, the way your library&#39;s components will be utilized.</p><a class="anchor" name="the_react_framework"></a><h2><a href="#the_react_framework">The React framework</a></h2><a class="anchor" name="what_s_react"></a><h3><a href="#what_s_react">What’s react?</a></h3><p>React is a JavaScript library developed by Facebook that specializes in rendering data as HTML and is widely used by websites such as Netflix, Imgur, Airbnb, and of course Facebook.</p><a class="anchor" name="why_develop_a_react_sdk"></a><h3><a href="#why_develop_a_react_sdk">Why develop a React SDK?</a></h3><p>An SDK or library provides a developer access to underlying functionality without exposing the complexity of the implementation. A library is most useful when it exposes the functionality using the syntax, components and methodology of the environment it is deployed in.
In Cloudinary’s case, we already provide a Cloudinary JavaScript library that can be used in any JavaScript based applications. However in order for us to support developers that are using React to create fast and responsive websites, we wanted to provide them with a convenient React library that they could use to deliver media from Cloudinary. In effect, we needed to provide React components that the developer can integrate directly in their application. These components in turn would take advantage of the functionality provided by the Cloudinary Core JavaScript library. 
The rest of this tutorial demonstrates how I developed our React library. This will not be a comprehensive description of our library but rather a guide that will (hopefully!) help you develop your own ReactJs library.</p><a class="anchor" name="basic_requirements"></a><h3><a href="#basic_requirements">Basic requirements</a></h3><p>Cloudinary provides a service for a cloud based storage, manipulation and delivery of images and other media content. Thus at minimum, a Cloudinary React library would need to deliver media resources from Cloudinary, as well as define transformations on those resources. The library should also allow the developer to configure the Cloudinary service and configure the Cloudinary account (represented by the cloud_name) to deliver resources from.</p><p>Thus the scope of version 1.0 of our library is:</p>
<ul>
<li>Configuration</li>
<li>Image tag</li>
<li>Transformation parameters</li>
</ul>
<p>I added code samples to accompany this post in our repository. To review the code, issue the following commands:</p><div class="code-holder"><code class="code_inner"><pre>git clone https://github.com/cloudinary/cloudinary-react
git checkout library-how-to-step-1</pre></code></div><p>You will find a similar command line at the beginning of each section below. Use it to review the code described in that section.</p><a class="anchor" name="getting_to_work"></a><h2><a href="#getting_to_work">Getting to work</a></h2><a class="anchor" name="setting_up_the_project"></a><h3><a href="#setting_up_the_project">Setting up the project</a></h3><p>JavaScript is an implementation of the ECMAScript specifications with support for the different versions of ES differing between browsers and browser versions. As a library developer, you would like your library to be supported in as many clients as possible, and these days, that would imply using ES5 (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript" data-popup="true" rel="nofollow">more</a>).</p><p>Yet, while it may be possible to write a React program using plain ES5, React normally utilizes ES6 syntax as well as JSX, packing it all with webpack. ES6 (also known as EcmaScript 6 or ES2015) introduces many new features to JavaScript, including classes and scoped variables. JSX on the other hand, provides a convenient way to include HTML code in JavaScript.
When developing a library you can’t always know how it will be utilized. Thus we need to provide developers with sources that can be accessed directly, as well as a compiled JavaScript distribution file that can be imported directly in the browser.
In order to utilize these features, several libraries must be included in your project:</p>
<ul>
<li>The React libraries.</li>
<li>Babel - translates ES6 and JSX to the more widely supported ES5.</li>
<li>Webpack - packing javascript applications, and providing a development server.</li>
<li>The Cloudinary JavaScript library (duh!).</li>
</ul>
<p>Babel and Webpack each require a configuration file. You can see an example of the configuration at <a href="https://github.com/cloudinary/cloudinary-react/tree/library-how-to-step-1" data-popup="true" rel="nofollow">https://github.com/cloudinary/cloudinary-react/tree/library-how-to-step-1</a>.</p><h5>Folder structure</h5><p>Each component will reside in its own folder. A package.json file is also included in each folder to allow using the <code>“import ‘./folder_name’;”</code> syntax instead of the more verbose <code>“import ‘./folder_name/filename’;”</code> style.</p><p><a href ="http://res.cloudinary.com/cloudinary/image/upload/expanded_component_folder.png" target="_new" title="Expanded components folder" alt="Expanded components folder" ><img src = "http://res.cloudinary.com/cloudinary/image/upload/expanded_component_folder.png"></a></p><p>An alternative would be to have one JS file per component. When using this approach you also need to include an index.js file that exports the components.</p><p><a href ="http://res.cloudinary.com/cloudinary/image/upload/concise_component_folder.png" target="_new" title="Concise component folder" alt="Concise component folder"><img src = "http://res.cloudinary.com/cloudinary/image/upload/concise_component_folder.png"></a></p><p>There are pros and cons to each approach, but I’ll leave that discussion for another day.</p><a class="anchor" name="creating_the_image_component"></a><h3><a href="#creating_the_image_component">Creating the Image component</a></h3><div class="code-holder"><code class="code_inner"><pre>git checkout library-how-to-step-2</pre></code></div><p>The first Component we’ll implement will be used to display an image.
The image component should:</p>
<ul>
<li>Accept configuration parameters.</li>
<li>Accept transformation parameters.</li>
<li>Accept an image public ID (the image&#39;s unique identifier).</li>
<li>Render an <code>&lt;img&gt;</code> tag with a constructed URL to display the image.</li>
</ul>
<h5>Humble beginnings</h5><p>We will start by defining a simple image component. The component will accept a cloud name, public ID and dimensions, and will then create an <code>&lt;img&gt;</code> tag to render the image.
A React component can be defined as a function or as a class. We’ll define all Cloudinary components as classes. The difference between the function and class approach is discussed <a href="https://facebook.github.io/react/docs/state-and-lifecycle.html" data-popup="true" rel="nofollow">here</a>.</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> React, {Component, PropTypes} from <span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">react</span><span style="color:#710">'</span></span>;
<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">export</span> <span style="color:#080;font-weight:bold">default</span> <span style="color:#080;font-weight:bold">class</span> Image <span style="color:#080;font-weight:bold">extends</span> React.Component {
 constructor(props) {
   <span style="color:#080;font-weight:bold">super</span>(props);
 }

 render() {
   let cl = cloudinary.Cloudinary.<span style="color:#080;font-weight:bold">new</span>({<span style="color:#606">cloud_name</span>: <span style="color:#950">this</span>.props.cloudName});
   <span style="color:#080;font-weight:bold">var</span> {publicId, width, height} = <span style="color:#950">this</span>.props;
   <span style="color:#080;font-weight:bold">var</span> url = cl.url(publicId, {width, height, <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">return</span> (
     <span style="color:#070;font-weight:bold">&lt;img</span> <span style="color:#b48">src</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">url</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#070;font-weight:bold">/&gt;</span>
   );
 }
}

Image.propTypes = {
 <span style="color:#606">cloudName</span>: PropTypes.string.isRequired,
 <span style="color:#606">publicId</span>: PropTypes.string.isRequired,
 <span style="color:#606">width</span>: PropTypes.number,
 <span style="color:#606">height</span>: PropTypes.number
};
Image.defaultProps = {};</pre></div>
</div>
</div></div><p>Our component is simple enough. 
It declares 4 properties as well as their type and whether they are required.
The render method, which is invoked whenever the component needs to be rendered, uses the properties values to generate a Cloudinary URL, and returns an <code>&lt;img&gt;</code> tag with that URL.</p><h5>Seeing is believing</h5><p>Unlike an application, we can’t simply run our library to see the results. To test it, we’ll create a simple HTML page named “image.html” under the “samples” folder.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#34b">&lt;!DOCTYPE html&gt;</span>
<span style="color:#070;font-weight:bold">&lt;html</span> <span style="color:#b48">lang</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">en</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;head&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;meta</span> <span style="color:#b48">charset</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">UTF-8</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;title&gt;</span>Cloudinary Image Component<span style="color:#070;font-weight:bold">&lt;/title&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;script</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">../node_modules/react/dist/react.js</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;/script&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;script</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">../node_modules/react-dom/dist/react-dom.js</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;/script&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;script</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">https://unpkg.com/babel-standalone@6.15.0/babel.min.js</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;/script&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;script</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">../node_modules/cloudinary-core/cloudinary-core-shrinkwrap.js</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;/script&gt;</span>
   <span style="color:#070;font-weight:bold">&lt;script</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">../dist/cloudinary-react.js</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;/script&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/head&gt;</span>
<span style="color:#070;font-weight:bold">&lt;body&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">root</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&gt;</span>
<span style="color:#070;font-weight:bold">&lt;script</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/babel</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">&gt;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"> let Image = cloudinaryReact.Image;</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black"> ReactDOM.render(</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">         <span style="color:#070;font-weight:bold">&lt;Image</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">cloudName</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">demo</span><span style="color:#710">&quot;</span></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">sample</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>,</span>
<span style="background-color:hsla(0,0%,0%,0.07);color:black">   document.getElementById(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">root</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>
<span style="color:#070;font-weight:bold">&lt;/body&gt;</span>
<span style="color:#070;font-weight:bold">&lt;/html&gt;</span></pre></div>
</div>
</div></div><p>It works!</p><p>(Notice that we are using the babel-standalone library in order to translate JSX syntax in the browser!)</p><h5>Deciding what properties to expose</h5><p>A React component is affected by two sets of information: the properties and the state.
Generally speaking, properties are public and may be set by a parent of the component. State is private and is not accessed outside the component.</p><p>A Cloudinary image delivery URL may accept many parameters that affect the resulting image. Furthermore, Cloudinary keeps coming up with new options almost weekly. For these reasons, we want the component to be <em>forward compatible</em> - that is be able to accept new configuration options in the future.</p><p>There are two ways to implement the the configuration and transformation options:</p>
<ul>
<li>As two properties whose values are a collection of parameters.</li>
<li>As individual options.
The former option has the advantage of strongly typing the signature of the component - we know that there are two properties named, say, options and transformation. In addition, the developer can prepare the options and transformation objects in advance:</li>
</ul>
<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">options</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">cloudName:</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#b48">demo</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">publicId:</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#b48">sample</span><span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#F00;background-color:#FAA">}</span><span style="color:#F00;background-color:#FAA">}</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:#700">width:</span> <span style="color:#b48">100</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">crop:</span> <span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#b48">crop</span><span style="color:#F00;background-color:#FAA">&quot;</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></pre></div>
</div>
</div></div><p>Or,</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>let options={<span style="color:#606">publicId</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">secure</span>: <span style="color:#069">true</span>};
let transformation={<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">jpg</span><span style="color:#710">&quot;</span></span>, <span style="color:#606">width</span>: <span style="color:#00D">300</span>};

<span style="color:#070;font-weight:bold">&lt;Image</span> <span style="color:#b48">options</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">options</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#b48">transformation</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">transformation</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><p>The disadvantage is that they encapsulate the actual parameters and thus make the component less readable.</p><p>Compare this with the latter option. Here each configuration and transformation option is an individual property of the 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;Image</span> <span style="color:#b48">cloudName</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">demo</span><span style="color:#710">&quot;</span></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">sample</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">100</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:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">10</span><span style="color:#710">&quot;</span></span><span style="color:#070;font-weight:bold">/&gt;</span></pre></div>
</div>
</div></div><p>I think this is much nicer, don’t you?</p><h5>Back to the Future</h5><p><code>git checkout library-how-to-step-3</code></p><p>A React component’s properties must be declared. Property values are checked in development mode and will produce a warning if they are invalid. To keep the definition future-compatible, we need to automatically define all configuration and transformation properties. This is done by listing all configuration and transformation keys from the cloudinary_js library. For simplicity, we define all properties as strings.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>let allParams = cloudinary.Configuration.CONFIG_PARAMS.concat(cloudinary.Transformation.PARAM_NAMES);
Image.VALID_OPTIONS = allParams.map(camelCase);
Image.propTypes = typesFrom(Image.VALID_OPTIONS);</pre></div>
</div>
</div></div><p>This code segment uses two utility functions, provided by the Util module of the Cloudinary Core JavaScript library:</p>
<ul>
<li>camelCase - converts a string to CamelCase</li>
<li>typesFrom creates a properties definition object from an array of property names</li>
</ul>
<h5>Attributes</h5><p>When designing the component interface (mainly, the properties of the component), you should carefully consider its utilization. For example, the developer may wish to provide attributes for the resulting tags. To allow the developer to explicitly provide the tag attributes, we will use the Transformation.toHtmlAttributes() method. This method collects all the properties that have a name that starts with “html_”, adds additional attributes calculated from the input, and returns them all as a set of HTML attributes that can be assigned to an HTML tag.</p><p>The spread operator (...) is required to convert the attributes object to key=value sets for the component.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>let attributes = transformation.toHtmlAttributes();
<span style="color:#080;font-weight:bold">return</span> (
 <span style="color:#070;font-weight:bold">&lt;img</span> <span style="color:#F00;background-color:#FAA">{</span><span style="color:#b48">...attributes</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#b48">src</span>=<span style="color:#F00;background-color:#FAA">{</span><span style="color:#700">url</span><span style="color:#F00;background-color:#FAA">}</span> <span style="color:#070;font-weight:bold">/&gt;</span>
);</pre></div>
</div>
</div></div><a class="anchor" name="nested_components_adding_the_transformation_component"></a><h3><a href="#nested_components_adding_the_transformation_component">Nested components - adding the Transformation component</a></h3><p><code>git checkout library-how-to-step-4</code></p><p>A cloudinary resource can be defined using several transformations which are chained together.
We can represent this chain by providing an array of objects to the transformation property. But that brings us back to the complex properties approach which we want to avoid.</p><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">cloudName</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">demo</span><span style="color:#710">&quot;</span></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">sample</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">100</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:#b48">angle</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">10</span><span style="color:#710">&quot;</span></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="color:#700">width:</span> <span style="color:#b48">100</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">crop:</span> <span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#b48">crop</span><span style="color:#F00;background-color:#FAA">&quot;</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:#b48">width:</span> <span style="color:#b48">100</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">angle:</span> <span style="color:#b48">-10</span><span style="color:#F00;background-color:#FAA">,</span> <span style="color:#b48">crop:</span> <span style="color:#F00;background-color:#FAA">&quot;</span><span style="color:#b48">scale</span><span style="color:#F00;background-color:#FAA">&quot;</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></pre></div>
</div>
</div></div><p>To reduce this complexity, we introduce a new component: Transformation. This is a virtual component, i.e., it does not render to the DOM/HTML. Instead, it represents a transformation that affects the image 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;Image</span> <span style="color:#b48">cloudName</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">demo</span><span style="color:#710">&quot;</span></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">sample</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">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">100</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">crop</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">-10</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:#b48">width</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">&quot;</span><span style="color:#D20">100</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><p>The Transformation component should not render a DOM node or HTML tag. But its properties should be available to the encapsulating Image component.</p><p>Preventing the component from rendering is easy. Simply return null from the render method:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>render() {
  <span style="color:#080;font-weight:bold">return</span> <span style="color:#069">null</span>;
}</pre></div>
</div>
</div></div><p>Access to the encapsulated components is done through the children property (this.props.children). React also provides a convenience method to map over the children.
You should check the type of the child before using its properties.</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre>let childrenOptions = React.Children.map(<span style="color:#950">this</span>.props.children, child =&gt;{
 <span style="color:#080;font-weight:bold">if</span> (child.type &amp;&amp; child.type.name === <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>){
   <span style="color:#080;font-weight:bold">return</span> getOptions(child.props);
 } <span style="color:#080;font-weight:bold">else</span> {
   <span style="color:#080;font-weight:bold">return</span> {};
 }
});</pre></div>
</div>
</div></div><a class="anchor" name="what_next"></a><h3><a href="#what_next">What next?</a></h3><p>So far we created an image component and a transformation component. We figured out a way to declare the properties of the component dynamically to support all the parameters of the underlying cloudinary_js library. We also devised a way for the image component to gather properties from its children.</p><p>To complete the CloudinaryReact library we will need to create a <em>video component</em>. When you do this you will quickly realize that your are duplicating code between the components. This can be solved by moving shared code to the Util object, or by introducing a common ancestor class to both the image and video component. The React documentation advises the former method (see <a href="https://facebook.github.io/react/docs/composition-vs-inheritance.html#so-what-about-inheritance" data-popup="true" rel="nofollow">here</a> and <a href="https://reactjsnews.com/composing-components#move-over-mixins-use-higher-order-components" data-popup="true" rel="nofollow">here</a>), but we preferred the latter, as it produces a cleaner and more modular code. What’s your preference?</p><p>We will also need to tie our image components to the browser’s resize event in order to provide responsive behaviour - the automatic selection of image size to fit the viewing area.</p><p>Another feature that would be useful is the ability to define common configuration parameters for a group of components or the entire page. We chose to use context for this purpose even though the React documentation vehemently advises against it as it is considered to be experimental and may be removed in future releases of React. Instead they suggest using Redux or passing an entire component as a property. This may be right for an application but not for a library. The application the library is used in may not be a redux application. Passing the properties down to the children is also not practical as the components who require the information may not be direct descendents of the parent passing the configuration parameters. On the flip side, using context will require us to provide an alternative solution if the functionality is removed in a future release of React.</p><p>All this, however, is beyond the scope of this post. As soon as I get a break from my coding tasks, I’ll post the next post on this subject.</p><p><code>git checkout master</code></p><p>You can review the implementation of these ideas as well as other components in our Cloudinary React library, and of course suggest your solutions in the comments.</p>]]>
      </description>
      <author />
      <pubDate>Wed, 11 Jan 2017 13:39:47 +0000</pubDate>
      <link>http://cloudinary.com/blog/how_to_develop_a_react_library</link>
      <guid>http://cloudinary.com/blog/how_to_develop_a_react_library</guid>
    </item>
    <item>
      <title>How to build a CMS with Adonis: A Laravel-like MVC framework for Node - Part 2</title>
      <description>
        <![CDATA[<p><img alt="Adonis Part 2" height="330" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_blog_post.png" style="margin: 0 auto;display: block" title="Adonis Part 2" width="700" />
Even though Node is fun, easy and cheap to work with, we spend a lot of time writing boilerplate codes because structure and organization is missing.</p><p>In <a href="http://cloudinary.com/blog/how_to_build_a_cms_with_adonis_a_laravel_like_mvc_framework_for_node_part_1" data-popup="true">part 1</a>, we discussed the basics of Adonis, including how to setup Adonis projects, and create migrations, models, a few routes, and a controller to test the creation of new posts.</p><p>Now, let’s extend what we already know to reading posts, updating existing posts, deleting posts, and adding an image upload feature.</p><a class="anchor" name="reading_existing_posts"></a><h2><a href="#reading_existing_posts">Reading existing posts</a></h2><p>With the create feature implemented, we must have created posts in our store. These posts will be read from our store and displayed on the browser.</p><p>We need to update the index route to point to a controller, rather than sending a view directly as it already does:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// ./app/Http/routes.js</span>
...
<span style="color:#777">// What we had:</span>
<span style="color:#777">// Route.on('/').render('welcome');</span>
<span style="color:#777">// Update to:</span>
Route.get(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">/</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">PostController.index</span><span style="color:#710">'</span></span>);
...</pre></div>
</div>
</div></div><p>Next, we add an action method to our controller named <code>index</code>. This method will be responsible for fetching the data from our model and sending the data to our view:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// ./app/Http/Controllers/PostController.js</span>
...
* index(request, response) {
    const posts = yield Post.all();
    yield response.sendView(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">post/index</span><span style="color:#710">'</span></span>, {<span style="color:#606">posts</span>: posts.toJSON()});
}
...</pre></div>
</div>
</div></div><p>The route points to an existing method, which sends a view with our retrieved data. Let’s create this view:</p><div class="code-holder"><code class="code_inner"><pre>&lt;h2&gt;Articles &lt;a href=&quot;/new&quot; class=&quot;ui blue button&quot;&gt;New Post&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;ards&quot;&gt;
  {% for post in posts %}
  &lt;div class=&quot;card&quot;&gt;
    &lt;div class=&quot;content&quot;&gt;
        &lt;a class=&quot;header&quot;&gt;{{post.title}}&lt;/a&gt;
        &lt;div class=&quot;meta&quot;&gt;
            &lt;span class=&quot;date&quot;&gt;{{post.created_at}}&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class=&quot;description&quot;&gt;
        {{post.body.substring(0, 50)}}...
        &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  % else %}
  &lt;h3&gt; No posts found &lt;/h3&gt;
  {% endfor %}
&lt;/div&gt;</pre></code></div><p><img alt="Adonis Post" height="437" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_post.png" style="margin: 0 auto;display: block" title="Adonis Post" width="700" /></p><p><img alt="Adonis Post Title" height="430" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_post_titles.png" style="margin: 0 auto;display: block" title="Adonis Post Title" width="700" /></p><a class="anchor" name="reading_a_single_post"></a><h3><a href="#reading_a_single_post">Reading a single post</a></h3><p>One other form of showing posts is reading and displaying a single post, which gives us more room for the details about the post. To do this, you need a route and a controller. Here is the route:</p><div class="code-holder"><code class="code_inner"><pre>// ./app/Http/routes.js
Route.get(&#x27;/post/:id&#x27;, &#x27;PostController.read&#x27;);</pre></code></div><p>The <code>:id</code> part of the URL is a placeholder for the route parameter. The parameter will be a unique value that points to a given post.</p><div class="code-holder"><code class="code_inner"><pre>// ./app/Http/Controllers/PostController.js
* read(request, response) {
     // Receive parameter from request
     const id = request.param(&#x27;id&#x27;);
     // Find id with request parameter
     const post = yield Post.find(id);
     yield response.sendView(&#x27;post/read&#x27;, {post: post});
 }</pre></code></div><p>The controller’s read action method receives the <code>id</code> parameter from the <code>request</code> object. We then use the model’s <code>find</code> method to find a post based on the value passed in.</p><p>The view sent is named <code>read</code> in the post folder and we are passing the post data down to the view as well:</p><div class="code-holder"><code class="code_inner"><pre>&lt;h2&gt;{{post.title}}&lt;/h2&gt;
&lt;small&gt;{{post.created_at}}&lt;/small&gt;
&lt;p&gt;{{post.body}}&lt;/p&gt;</pre></code></div><p><img alt="Adonis Post Second Title" height="573" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_post_second_title.png" style="margin: 0 auto;display: block" title="Adonis Post Second Title" width="700" /></p><p>You can update the link for each post on the home page to point to the read URL:</p><div class="code-holder"><code class="code_inner"><pre>&lt;a class=&quot;header&quot; href=&quot;/post/{{post.id}}&quot;&gt;{{post.title}}&lt;/a&gt;</pre></code></div><a class="anchor" name="updating_posts"></a><h2><a href="#updating_posts">Updating posts</a></h2><p>What happens when we realize that our post requires an update? We can create a form just like we did for the new post form, but this time we will send the existing post to the form. First, we need to specify some routes, as usual:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#777">// ./app/Http/routes.js</span>
<span style="color:#777">// Edit form</span>
Route.get(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">/edit/:id</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">PostController.edit</span><span style="color:#710">'</span></span>);
Route.post(<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">/update</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">PostController.update</span><span style="color:#710">'</span></span>);</pre></div>
</div>
</div></div><p>With respect to the routes above, the following action methods will serve as handlers for both routes:</p><div class="code-holder"><code class="code_inner"><pre>* edit(request, response) {
    const id = request.param(&#x27;id&#x27;);
    const post = yield Post.find(id);
    yield response.sendView(&#x27;post/edit&#x27;, {post: post});
}
* update(request, response) {
    var postData = request.only(&#x27;id&#x27;, &#x27;title&#x27;, &#x27;body&#x27;);
    const id = postData.id;
    const post = yield Post.find(id);
    // Update and save post
    post.fill(postData);
    yield post.save();
    // Go home
    response.redirect(&#x27;/&#x27;);
}</pre></code></div><p>The <code>edit</code> action method sends a view. This view will hold our form template for editing the selected post:</p><div class="code-holder"><code class="code_inner"><pre>  &lt;h2&gt;{{post.title}}&lt;/h2&gt;
  {{ form.open({action: &#x27;PostController.update&#x27;}) }}

    {{ csrfField }}

    &lt;div class=&quot;ui form&quot;&gt;
        &lt;div class=&quot;field&quot;&gt;
            {{ form.label(&#x27;Title&#x27;) }}
            {{ form.text(&#x27;title&#x27;, post.title) }}
        &lt;/div&gt;

        &lt;div class=&quot;field&quot;&gt;
            {{ form.label(&#x27;Body&#x27;) }}
            {{ form.textarea(&#x27;body&#x27;, post.body) }}
        &lt;/div&gt;

        {{form.hidden(&#x27;id&#x27;, post.id)}}

        {{ form.submit(&#x27;Create&#x27;, &#x27;create&#x27;, { class: &#x27;ui blue button&#x27; }) }}
    &lt;/div&gt;

  {{ form.close() }}</pre></code></div><p>The default values are set using the existing values in our store. The post’s <code>id</code> is also available on the form via a hidden input.</p><p>For each post listed on the home page, we&#39;ll also add an edit button that points to the relevant edit URL:</p><div class="code-holder"><code class="code_inner"><pre>...
&lt;a class=&quot;ui basic green button&quot; href=&quot;/edit/{{post.id}}&quot;&gt;Edit&lt;/a&gt;
...</pre></code></div><a class="anchor" name="deleting_posts"></a><h2><a href="#deleting_posts">Deleting posts</a></h2><p>The route for deleting post is very similar to the <code>read</code> and <code>edit</code> routes. It takes a parameter for searching the post to be removed:</p><div class="code-holder"><code class="code_inner"><pre>Route.get(&#x27;/delete/:id&#x27;, &#x27;PostController.delete&#x27;);</pre></code></div><p><strong>Note</strong>: Best practices suggest that you do not use <code>GET</code> to update state as we are doing right now. For the sake of this demo’s simplicity, we can overlook that practice.</p><p>The action method on the controller is <code>delete</code> and it finds the post based on the <code>id</code> parameter and then deletes the found post:</p><div class="code-holder"><code class="code_inner"><pre>* delete(request, response) {
    var post = yield Post.find(request.param(&#x27;id&#x27;));
    yield post.delete();
    response.redirect(&#x27;/&#x27;);
}</pre></code></div><p>We can add a link to the post list to point to the delete URL:</p><div class="code-holder"><code class="code_inner"><pre>&lt;a class=&quot;ui basic red button&quot; href=&quot;/delete/{{post.id}}&quot;&gt;Delete&lt;/a&gt;</pre></code></div><a class="anchor" name="featured_image_uploads"></a><h2><a href="#featured_image_uploads">Featured image uploads</a></h2><p>Contents are always accompanied with images. In the case of a CMS, these images could be embedded right inside the content or serve as a banner to a given content. The banner is usually known as a featured image.</p><p><a href="http://cloudinary.com/" data-popup="true">Cloudinary</a> is the image management back-end for web and mobile developers. With Cloudinary, we can add images to our content with ease, thereby saving as the hassle of managing storage, as well as image uploads, downloads, manipulation, delivery and administration.</p><p>With the Cloudinary <a href="https://cloudinary.com/users/register/free" data-popup="true">free account</a>, we can begin using these features in our projects. Let’s see how by adding a featured image to our posts.</p><p>After you set up a Cloudinary account, you can create an <a href="http://cloudinary.com/documentation/upload_images#upload_presets" data-popup="true">upload preset</a>. Upload presets enable you to centrally define a set of image upload options instead of specifying them in each upload call. We will use the preset when making an upload request.</p><p>Cloudinary provides JavaScript plugins that make image upload to the Cloudinary server very easy. Here’s how we include these scripts:</p><div class="code-holder "><div class="code_inner"><div class="CodeRay">
  <div class="code"><pre><span style="color:#070;font-weight:bold">&lt;script</span> <span style="color:#b48">src</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">https://cdn.jsdelivr.net/jquery.cloudinary/1.0.18/jquery.cloudinary.js</span><span style="color:#710">'</span></span> <span style="color:#b48">type</span>=<span style="background-color:hsla(0,100%,50%,0.05)"><span style="color:#710">'</span><span style="color:#D20">text/javascript</span><span style="color:#710">'</span></span><span style="color:#070;font-weight:bold">&gt;</span><span style="color:#070;font-weight:bold">&lt;/script&gt;</span>
<span style="color:#070;font-weight:bold">&lt;script</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">//widget.cloudinary.com/global/all.js</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">text/javascript</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;/script&gt;</span>
<span style="color:#070;font-weight:bold">&lt;script</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">/script.js</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;/script&gt;</span></pre></div>
</div>
</div></div><p>The plugin depends on jQuery, so we also added our defined <code>script.js</code> file to the setup.</p><p>In the <code>script.js</code> file, we can start implementing the upload logic:</p><div class="code-holder"><code class="code_inner"><pre>$(function() {
    // Configure Cloudinary
    // with credentials available on
    // your Cloudinary account dashboard
    $.cloudinary.config({ cloud_name: &#x27;YOUR_CLOUD_NAME&#x27;, api_key: &#x27;YOUR_API_KEY&#x27;});

    // Upload button
    var uploadButton = $(&#x27;#upload-button&#x27;);
    var canvas = $(&#x27;#canvas&#x27;);
    var imageInput = $(&#x27;#image-input&#x27;);
    // Upload button event
    uploadButton.on(&#x27;click&#x27;, function(e){
        // Initiate upload
        cloudinary.openUploadWidget({ cloud_name: &#x27;christekh&#x27;, upload_preset: &#x27;idcidr0h&#x27;, tags: [&#x27;cgal&#x27;]}, 
        function(error, result) { 
            if(error) console.log(error);
            // If NO error, log image data to console
            var id = result[0].public_id;
            canvas.html(procesImage(id));
            imageInput.val($.cloudinary.url(id, {}));
        });
    });
})

function procesImage(id) {
    var options = {
        client_hints: true,
    };
    return &#x27;&lt;img src=&quot;&#x27;+ $.cloudinary.url(id, options) +&#x27;&quot; style=&quot;width: 100%; height: auto&quot;/&gt;&#x27;;
}</pre></code></div><p>The above listens to a <code>click</code> event on a button in our view. When the button is clicked, the upload process starts. After an image is uploaded and returned, the image is displayed above the form. The URL is also embedded in a <code>hidden</code> input so it can be sent to the server and stored for future use, as well.</p><p>Going back to the <code>posts/new</code> view we already created, we can extend it to handle the logic we have prepared:</p><div class="code-holder"><code class="code_inner"><pre>&lt;h2&gt;New Post&lt;/h2&gt;
    &lt;div class=&quot;paint_container&quot; id=&quot;canvas&quot;&gt;
        &lt;!-- Canvas to drop image after processing --&gt;
    &lt;/div&gt;
  {{ form.open({action: &#x27;PostController.create&#x27;}) }}

    {{ csrfField }}

    &lt;div class=&quot;ui form&quot;&gt;
        &lt;div class=&quot;field&quot;&gt;
            {{ form.label(&#x27;Title&#x27;) }}
            {{ form.text(&#x27;title&#x27;, null) }}
        &lt;/div&gt;

        &lt;div class=&quot;field&quot;&gt;
            {{ form.label(&#x27;Body&#x27;) }}
            {{ form.textarea(&#x27;body&#x27;, null) }}
        &lt;/div&gt;

        &lt;input type=&quot;hidden&quot; id=&quot;image-input&quot; name=&quot;image&quot;&gt;

        &lt;button id=&quot;upload-button&quot; class=&quot;ui purple button&quot; type=&quot;button&quot;&gt;Upload Featured Image&lt;/button&gt;

        {{ form.submit(&#x27;Create&#x27;, &#x27;create&#x27;, { class: &#x27;ui blue button&#x27; }) }}
    &lt;/div&gt;

  {{ form.close() }}</pre></code></div><p><img alt="Adonis New Post" height="512" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_new_post.png" style="margin: 0 auto;display: block" title="Adonis New Post" width="700" /></p><p>The image also gets stored in our database, so we can also display it on the home page where we list the posts:</p><div class="code-holder"><code class="code_inner"><pre>...
&lt;div class=&quot;card&quot;&gt;
    &lt;div class=&quot;image&quot;&gt;
        &lt;img src=&quot;{{post.image}}&quot; syyle=&quot;width: 100%; heigth: auto;&quot;&gt;
    &lt;/div&gt;
   ...</pre></code></div><p><img alt="Adonis Finished Post" height="512" src="http://res.cloudinary.com/cloudinary/image/upload/w_700/adonis_finished_post.png" style="margin: 0 auto;display: block" title="Adonis Finished Post" width="700" /></p><p>Have a look at the <a href="https://github.com/christiannwamba/adonis-cloudinary-cms" data-popup="true" rel="nofollow">complete demo project</a>.</p><a class="anchor" name="conclusion"></a><h2><a href="#conclusion">Conclusion</a></h2><p>Adonis is an awesome framework that is great to work with because of its simplicity. Media management can cause you sleepless nights, not just with Adonis, but any server-side framework. Cloudinary eliminates the stress and shortens the time you spend on media management, enabling you to focus on building out the other aspects of your application.</p>
<table>
<tr>
<td style = "padding: 5px;">
<img src="http://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/chrizt_n" target="_new">Christian Nwamba</a> is a code beast, with a passion for instructing computers and understanding it's language. In his next life, Chris hopes to remain a computer programmer.</i></td>
</tr>
</table>
]]>
      </description>
      <author>Christian Nwamba</author>
      <pubDate>Wed, 04 Jan 2017 13:44:42 +0000</pubDate>
      <link>http://cloudinary.com/blog/how_to_build_a_cms_with_adonis_a_laravel_like_mvc_framework_for_node_part_2</link>
      <guid>http://cloudinary.com/blog/how_to_build_a_cms_with_adonis_a_laravel_like_mvc_framework_for_node_part_2</guid>
    </item>
  </channel>
</rss>
