{"id":21951,"date":"2019-09-18T14:03:17","date_gmt":"2019-09-18T14:03:17","guid":{"rendered":"http:\/\/how_to_use_displacement_maps_to_transform_images"},"modified":"2025-02-25T15:23:57","modified_gmt":"2025-02-25T23:23:57","slug":"how_to_use_displacement_maps_to_transform_images","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images","title":{"rendered":"Displacement Maps for Easy Image Transformations with Cloudinary"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>With Cloudinary\u2019s transformation options, you as web or mobile developers can transform images in real time through dynamic URLs, from <a href=\"https:\/\/cloudinary.com\/blog\/image_optimization_for_websites_beautiful_pages_that_load_quickly\">optimization<\/a> and <a href=\"https:\/\/cloudinary.com\/blog\/make_all_images_on_your_website_responsive_in_3_easy_steps\">responsive delivery<\/a> to other tasks, complete with cool effects. For example, a robust transformation applies another image to displace your base image with a mapping algorithm that evaluates the base image\u2019s pixels, displacing them according to the intensity of the corresponding image\u2019s map pixels.<\/p>\n<p>Specifically, the algorithm appraises the map image\u2019s red and green channels: the more intense the red color in the displacement map, the more the horizontal displacement of the corresponding pixel in the base image. Similarly, the more intense the green color in the displacement map, the larger the vertical displacement of the corresponding pixel in the base image.<\/p>\n<h2>How Do You Create a Displacement Map?<\/h2>\n<p>The following example demonstrates a base image displaced by an image map, creating a zoom effect:<\/p>\n<p><a class=\"c-image-link\" href=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/docs\/displace_magnify.jpg\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/docs\/displace_magnify.jpg\" alt=\"displacement map for a zoom effect\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1186\" height=\"695\"\/><\/a><\/p>\n<p><\/p>\n<p>The next example uses a displacement map to warp the perspective of an overlay image for final placement as an overlay on another image:<\/p>\n<p><a class=\"c-image-link\" href=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/docs\/displace_radialize.jpg\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/docs\/displace_radialize.jpg\" alt=\"displacement map for image overlay\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1186\" height=\"695\"\/><\/a><\/p>\n<p><\/p>\n<p>Using this overlay transformation for placement on a mug:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/demo-res.cloudinary.com\/w_500\/l_sample.png,c_pad,w_250,h_250\/l_radialize\/fl_layer_apply,e_displace,y_-8\/fl_layer_apply,x_10,b_transparent\/left_mug\" alt=\"Zoom displacement map\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"500\" height=\"500\"\/><\/p>\n<p><\/p>\n<h2>The Displacement Effect<\/h2>\n<p>The displacement effect is controlled by a few configurable parameters that allow you to fine tune the desired result. The dynamic URL for the final image includes:<\/p>\n<ul>\n<li>The public_id of the base image.<\/li>\n<li>The public_id of the image map to use as a displacement template, added using the <code>overlay<\/code> parameter (<code>l<\/code> in URLs).<\/li>\n<li>The <code>effect<\/code> parameter set to <code>displace<\/code> (<code>e_displace<\/code> in URLs), which tells Cloudinary to use the image map as a displacement effect rather than adding it as an overlay.<\/li>\n<li>The <code>x<\/code> and <code>y<\/code> parameters to configure the maximum allowed displacement in the horizontal and vertical directions (negative values for left and up respectively, 0 for no displacement).<\/li>\n<\/ul>\n<p>The final displacement of each pixel in the base image is determined by a combination of the red and green color channels, together with the configured x and y parameters. For example, for a given x value of 20 and a pixel with a red value of 255 (highest), the corresponding base image pixel would be displaced by 20 pixels horizontally, while a red value of 25 (10%) would only displace the base image pixel by 2 pixels horizontally.<\/p>\n<p>The following example demonstrates the zoom displacement map shown above (along with an overlay of a magnifying glass) to \u201cmagnify\u201d the base image.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/demo-res.cloudinary.com\/w_500,h_500,c_fill\/l_woman,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_20,y_20\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_20,y_20\/fl_layer_apply,g_north_west,x_20,y_20\/l_mag-glass.png,w_330,h_215,g_north_west,x_38,y_38,fl_no_overflow\/woman.jpg\" alt=\"zoomed in image\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"500\" height=\"500\"\/><\/p>\n<h2>Custom Art Effects<\/h2>\n<p>Any image can be used as a displacement map, even if it hasn\u2019t been specifically created for that purpose. Most of the time, using a photograph as a map will give some surreal effects, but if you use a photograph with a (semi) repeating pattern, you can actually end up with some nice new texture effects. The following interactive example allows you to combine a base picture with various image \u201ctextures\u201d:<\/p>\n<div style=\"padding: 5px;border:3px solid black;\">\n<span class=\"step_number\">1<\/span>&nbsp;&nbsp;Select the strength of the distortion effect:&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"number\" name=\"color-quantity\" id=\"color-quantity\" align=\"middle\" value=\"10\" min=\"2\" max=\"100\">\n<div style=\"clear: both; margin-bottom: 30px\">\n<\/div>\n<span class=\"step_number\">2<\/span>&nbsp;&nbsp;Pick an image to use as a distortion effect\n<div style=\"clear: both; margin-bottom: 10px\">\n<\/div>\n<div style=\"text-align:center;padding-top: 5px;\">\n<span style=\"display:inline-block;vertical-align:top;\">\n<img decoding=\"async\"  id=\"photo1\" data-url-choice=\"photo1\" data-url-image=\"water\" class=\"photo-img\" width=100 height=100 src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_100,h_100,c_fill,dpr_2.0\/docs\/water.jpg\" alt=\"water\" title=\"water\" style=\"margin-right:0px;margin-left: 0px;display:block;\" \/><\/a>\n<\/span>\n<span style=\"display:inline-block;vertical-align:top;\">\n<img decoding=\"async\" id=\"photo2\" data-url-choice=\"photo2\" data-url-image=\"pebbles\" class=\"photo-img\" width=100 height=100 src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_100,h_100,c_fill,dpr_2.0\/docs\/pebbles.jpg\" alt=\"pebbles\" title=\"pebbles\" style=\"margin-right:0px;display:block;\" \/><\/a>\n<\/span>\n<span style=\"display:inline-block;vertical-align:top;\">\n<img decoding=\"async\" id=\"photo3\" data-url-choice=\"photo3\" data-url-image=\"concrete\" class=\"photo-img\" width=100 height=100 src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_100,h_100,c_fill,dpr_2.0,g_face\/docs\/concrete.jpg\" alt=\"concrete\" title=\"concrete\" style=\"margin-right:0px;display:block;\" \/><\/a>\n<\/span>\n<\/div>\n<div style=\"clear: both; margin-bottom: 50px\">\n<\/div>\n<span class=\"step_number\">3<\/span>&nbsp;&nbsp;Press the button!\n<div style=\"text-align:center\">\n<span class=\"apply-button\" id=\"neural_apply\">\n<button id=\"apply-this-button\" class=\"cloudinary-button\">Generate image<\/button>\n<\/span>\n<div style=\"clear: both; margin-bottom: 10px\">\n<\/div>\n<div>\n<span align=\"center\" style=\"padding: 5px;max-width:70%;display:inline-block;vertical-align:top;\">\n<a id=\"imagelink\" href=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/base.jpg\" target =\"_blank\" data-url-template3=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_style_transfer,l_#art_image#\/#use-img#.jpg\">\n<img decoding=\"async\" id=\"testpic\" src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_550,h_300,c_fit\/base.jpg\" alt=\"Your generated image\" title=\"Your generated image\"  data-url-template=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_style_transfer,l_#art_image#\/#use-img#.jpg\" \/>\n<\/a>\n<div align=\"center\" class=\"div_url\" style=\"font-size: 90%;\">\n <a id=\"cloudurl\" href=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:water,y_10,x_10\/docs\/colored_pencils.jpg\" target=\"_blank\" data-url-templated=\"\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:#use-img#,y_#art_image_x#,x_#art_image_y#\/docs\/colored_pencils.jpg\"\"><span id=\"c-url\">&#8220;https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:water,y_10,x_10\/docs\/colored_pencils.jpg&#8221;<\/span><\/a>\n<p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h2>Adapting Overlays to a Non-smooth Surface<\/h2>\n<p>Another more practical case for using the displacement effect is to make an overlay appear more realistic when placing it over an object with its own texture, making the overlay seem like its actually part of that object itself.  This can be very useful for generating customized eCommerce images.<\/p>\n<p>This can be achieved by using the base image itself as a displacement map for the overlay. For example, below we\u2019ve added an overlay to a sweater, using the sweater itself as a displacement map for the overlay:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/demo-res.cloudinary.com\/image\/upload\/w_490,o_80\/c_pad,h_2.0,w_1.0\/l_docs:sweater,e_displace,y_-8\/e_trim\/u_docs:sweater,w_690\/docs\/bulls.png\" alt=\"Adapting overlay to a surface\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"690\" height=\"518\"\/><\/p>\n<h2>Final Displacements<\/h2>\n<p>Displacement maps can be a useful addition to your arsenal of image transformations. They allow you to customize your images in interesting ways and add realistic effects. This capability is already being used by our customers to displace images overlays, and as shown in this post, can also be used in multiple, perhaps unexpected ways. The feature is available for use with all Cloudinary accounts, including the <a href=\"https:\/\/cloudinary.com\/users\/register\/free\">free tier<\/a>.<\/p>\n<div>\n<style>\ntable{\n    table-layout: fixed;\n}\n<p>.art-img:hover  {\nborder: solid 6px #aaa;\nborder-radius: 6px;\ncursor: pointer;\nopacity: 1;<\/p>\n<p>}\n.step_number {\nbackground:  black;\ncolor:  white;\nwidth: 24px;\nheight: 24px;\ndisplay: inline-block;\ntext-align: center;\nline-height: 24px;\nborder-radius: 100px;\n}\n.art-img {\nborder: solid 6px white;\nborder-radius: 6px;\nopacity: 0.5;<\/p>\n<p>}\n.art-img.active {\nborder: solid 6px black;\nborder-radius: 6px;\nopacity: 1;<\/p>\n<p>}\n.photo-img:hover  {\nborder: solid 6px #aaa;\nborder-radius: 6px;\ncursor: pointer;\nopacity: 1;<\/p>\n<p>}\n.photo-img {\nborder: solid 6px #aaa;\nborder-radius: 6px;\nopacity: 0.5;<\/p>\n<p>}\n.photo-img.active {\nborder: solid 6px black;\nborder-radius: 6px;\nopacity: 1;<\/p>\n<p>}\n.source-img:hover  {\nborder: solid 6px #aaa;\nborder-radius: 6px;\ncursor: pointer;\nopacity: 1;<\/p>\n<p>}\n.source-img {\nborder: solid 6px #aaa;\nborder-radius: 6px;\nopacity: 0.5;<\/p>\n<p>}\n.source-img.active {\nborder: solid 6px black;\nborder-radius: 6px;\nopacity: 1;<\/p>\n<p>}<\/p>\n<p>.apply-button:hover  {\ncursor: pointer;<\/p>\n<p>}\n<\/style><\/p>\n<\/div>\n<script src=\"\/\/widget.cloudinary.com\/global\/all.js\" type=\"text\/javascript\"><\/script>   \n<script type=\"text\/javascript\"> \nvar A = \"custom\";\nvar B = document.getElementById(\"color-quantity\").value; \nvar C = \"custom\";\nvar X  = \"50\";\nvar Y = \"50\";\nvar Z = \"20\";\n\nfunction updateResult(result) {\n    var $display = \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n  var $urldisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n    var $linkdisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n    var $source = $('#testsource');   \n    var widget_id = result[\"public_id\"];\n    C =   widget_id;\n\n\n \n\n    var newUrl = $display.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n    var newUrl2 = $urldisplay.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n    var newUrl3 = $linkdisplay.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n\n     var newUserUrl = $userpic.replace('#upic#', C); \n\n\n    var $ccloudurl = $('#sourceurl');\n    document.getElementById(\"source-url\").textContent=newUrl2;\n    $source.attr('src', newUrl);\n    $ccloudurl.attr('href', newUrl2);    \n    $imglink.attr('href', newUrl3);\n   $('#source4').attr('src', newUserUrl).data('url-image', widget_id);\n\n     $('.source-img').removeClass('active');\n     $('#source4').addClass('active');\n  };\n\n\n\ndocument.getElementById(\"sourcelink\").addEventListener(\"click\", getClickPosition, false);\n\n\nfunction getClickPosition(e) {\n    X = e.clientX;\n    Y = e.clientY;\n\n\n var $display = \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n  var $urldisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n    var $linkdisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n    var $source = $('#testsource');   \n\n    var newUrl = $display.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n    var newUrl2 = $urldisplay.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n    var newUrl3 = $linkdisplay.replace('#use-img#', C).replace('#x_val#', X).replace('#y_val#', Y).replace('#z_val#', Z);\n\n     var newUserUrl = $userpic.replace('#upic#', C); \n\n\n    var $ccloudurl = $('#sourceurl');\n    document.getElementById(\"source-url\").textContent=newUrl2;\n    $source.attr('src', newUrl);\n    $ccloudurl.attr('href', newUrl2);    \n    $imglink.attr('href', newUrl3);\n\n\n}\n\n\n\n  document.getElementById(\"upload_widget_opener\").addEventListener(\"click\", function(e) {\n     e.preventDefault();\n    cloudinary.openUploadWidget({ cloud_name: 'demo', upload_preset: 'st_blog',\n    sources: ['local','url','camera','dropbox', 'image_search','google_photos', 'facebook'], google_api_key: 'AIzaSyDaQj7FO1IQtp9DSB5YNP5jjG6f_mItEQ4'}, \n      function(error, result) { console.log(result[0].public_id);  console.log(error, result); updateResult(result[0]) });\n  }, false);\n\n\n<\/script>\n<script>\n \/\/<![CDATA[   \n\n\n function insertScript(src, callback) {\n  var script = document.createElement('script');\n  script.onload = callback;\n  script.type = 'text\/javascript';\n  script.async = true;\n  script.src = src;\n  var s = document.getElementsByTagName('script')[0];\n  s.parentNode.insertBefore(script, s);\n }\n insertScript('\/javascripts\/jquery.min.js', function(){\n \n  $('.apply-button').click(function(){\n\n\n  \tvar $display = \"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:#use-img#,y_#art_image_x#,x_#art_image_y#\/docs\/colored_pencils.jpg\"\n    var $urldisplay = \"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:#use-img#,y_#art_image_x#,x_#art_image_y#\/docs\/colored_pencils.jpg\"\n    var $linkdisplay = \"https:\/\/res.cloudinary.com\/demo\/image\/upload\/e_displace,l_docs:#use-img#,y_#art_image_x#,x_#art_image_y#\/docs\/colored_pencils.jpg\"\n\n    var $imglink = $('#imagelink');\n    var $img = $('#testpic');  \n\n    if (A == \"custom\") {\n      return;\n    }\n\n    if (!A) {\n      A = \"water\"\n    }\n    B = document.getElementById(\"color-quantity\").value; \n    if (!B) {\n      B = \"6\"\n    }\n \n    var newUrl = $display.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n    var newUrl2 = $urldisplay.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n    var newUrl3 = $linkdisplay.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n\n    \n    var $ccloudurl = $('#cloudurl');\n    document.getElementById(\"c-url\").textContent=newUrl2;\n    $img.attr('src', newUrl);\n    $ccloudurl.attr('href', newUrl2);    \n    $imglink.attr('href', newUrl3);\n\n  });\n\n  $('.apply-magnify-button').click(function(){\n\nvar $display = \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n  var $urldisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n    var $linkdisplay =  \"https:\/\/demo-res.cloudinary.com\/$x_#x_val#,$y_#y_val#,$z_#z_val#,$img_current\/w_500,h_500,c_fill\/l_$img,w_500,h_500,c_fill\/w_200,h_200,c_crop,x_$x,y_$y\/c_fill,w_200,h_200,l_docs:zoom_map\/fl_layer_apply,e_displace,x_$z,y_$z\/fl_layer_apply,g_north_west,x_$x,y_$y\/l_mag-glass.png,w_330,h_215,g_north_west,x_$x_add_18,y_$y_add_18,fl_no_overflow\/#use-img#.jpg\"\n\n    var $imglink = $('#imagelink');\n    var $img = $('#testpic');  \n\n    if (A == \"custom\") {\n      return;\n    }\n\n    if (!A) {\n      A = \"water\"\n    }\n    B = document.getElementById(\"color-quantity\").value; \n    if (!B) {\n      B = \"6\"\n    }\n \n    var newUrl = $display.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n    var newUrl2 = $urldisplay.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n    var newUrl3 = $linkdisplay.replace('#use-img#', A).replace('#art_image_x#', B).replace('#art_image_y#', B);\n\n    \n    var $ccloudurl = $('#cloudurl');\n    document.getElementById(\"c-url\").textContent=newUrl2;\n    $img.attr('src', newUrl);\n    $ccloudurl.attr('href', newUrl2);    \n    $imglink.attr('href', newUrl3);\n\n  });\n\n  $('.photo-img').click(function(){\n\n    var $sender = $(this);\n    A =  $sender.data('url-image');\n     $('.photo-img').removeClass('active');\n   $sender.addClass('active');\n\n\n  });\n\n  $('.source-img').click(function(){\n\n    var $sender = $(this);\n    A =  $sender.data('url-image');\n     $('.source-img').removeClass('active');\n   $sender.addClass('active');\n\n\n  });\n\n  $('.art-img').click(function(){\n\n  \tvar $sender = $(this);\n    B =  $sender.data('url-image');\n     $('.art-img').removeClass('active');\n   $sender.addClass('active');\n  \n  });\n\n });\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\n\n \/\/]]>\n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":21952,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[162,165],"class_list":["post-21951","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-image-processing","tag-image-transformation"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Displacement Maps for Easy Image Transformations with Cloudinary<\/title>\n<meta name=\"description\" content=\"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Displacement Maps for Easy Image Transformations with Cloudinary\" \/>\n<meta property=\"og:description\" content=\"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-18T14:03:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-25T23:23:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog-jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"1540\" \/>\n\t<meta property=\"og:image:height\" content=\"847\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"Displacement Maps for Easy Image Transformations with Cloudinary\",\"datePublished\":\"2019-09-18T14:03:17+00:00\",\"dateModified\":\"2025-02-25T23:23:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\"},\"wordCount\":8,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA\",\"keywords\":[\"Image Processing\",\"Image Transformation\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2019\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\",\"url\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\",\"name\":\"Displacement Maps for Easy Image Transformations with Cloudinary\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA\",\"datePublished\":\"2019-09-18T14:03:17+00:00\",\"dateModified\":\"2025-02-25T23:23:57+00:00\",\"description\":\"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA\",\"width\":1540,\"height\":847},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Displacement Maps for Easy Image Transformations with Cloudinary\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Displacement Maps for Easy Image Transformations with Cloudinary","description":"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images","og_locale":"en_US","og_type":"article","og_title":"Displacement Maps for Easy Image Transformations with Cloudinary","og_description":"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.","og_url":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images","og_site_name":"Cloudinary Blog","article_published_time":"2019-09-18T14:03:17+00:00","article_modified_time":"2025-02-25T23:23:57+00:00","og_image":[{"width":1540,"height":847,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog-jpg?_i=AA","type":"image\/jpeg"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images"},"author":{"name":"","@id":""},"headline":"Displacement Maps for Easy Image Transformations with Cloudinary","datePublished":"2019-09-18T14:03:17+00:00","dateModified":"2025-02-25T23:23:57+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images"},"wordCount":8,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA","keywords":["Image Processing","Image Transformation"],"inLanguage":"en-US","copyrightYear":"2019","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images","url":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images","name":"Displacement Maps for Easy Image Transformations with Cloudinary","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA","datePublished":"2019-09-18T14:03:17+00:00","dateModified":"2025-02-25T23:23:57+00:00","description":"How displacement maps can be used in multiple ways to transform your images and achieve various effects and transformations.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA","width":1540,"height":847},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/how_to_use_displacement_maps_to_transform_images#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Displacement Maps for Easy Image Transformations with Cloudinary"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649734602\/Web_Assets\/blog\/displacement_map_blog\/displacement_map_blog.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/21951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=21951"}],"version-history":[{"count":3,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/21951\/revisions"}],"predecessor-version":[{"id":37018,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/21951\/revisions\/37018"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/21952"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=21951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=21951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=21951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}