{"id":27864,"date":"2023-07-24T07:00:00","date_gmt":"2023-07-24T14:00:00","guid":{"rendered":"http:\/\/zoom-and-rotate-image-in-reactjs"},"modified":"2025-10-16T10:40:53","modified_gmt":"2025-10-16T17:40:53","slug":"zoom-and-rotate-image-in-reactjs","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs","title":{"rendered":"Zoom and Rotate Image in ReactJS"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><p>React allows you to transform images with zoom and rotate functionality. When you know the prompts, it\u2019s easy to transform you images to align them perfectly to your design objectives.<\/p>\n<p>To be clear, React image zoom means enlarging an image so that the details are more visible using ReactJS. Zooming in on a picture has many wide applications ranging from zooming through a camera lens to zooming in on a photo on the internet.<\/p>\n<p>On the other hand, to rotate an image in React is an image processing feature that allows you to turn an image in a clockwise or counterclockwise direction.<\/p>\n<p>In this post, you\u2019ll learn how to zoom and rotate images with React in three ways: the React-image-zoom package, Cloudinary, and React.js.<\/p>\n<p>Additionally, for those looking to handle rotations using native CSS properties in React, we will also delve into methods like<code> transform: rotate()<\/code>, <code>transform-origin<\/code>, and <code>transition<\/code> to achieve the same effect.<\/p>\n<p><a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">React-image-zo<\/a><a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">o<\/a><a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">om<\/a> is an npm package that will allow users to zoom in on images. This component has minimal styling footprint. In addition, we can pass in custom class names and id props that\u2019ll enable us to customize the package to fit our design needs.<\/p>\n<p><a href=\"https:\/\/cloudinary.com\/\">Cloudinary<\/a> Image APIs make it easy to upload, store, manage, transform, and deliver images and videos for web and mobile applications.<\/p>\n<h2>Sandbox<\/h2>\n<p>The complete project is on <a href=\"https:\/\/codesandbox.io\/embed\/focused-pare-kx8jdl?fontsize=14&amp;hidenavigation=1&amp;theme=dark\">CodeSandbox below<\/a>. Use the link in the sandbox to fork and run it to quickly get started.<\/p>\n<iframe src=\"https:\/\/codesandbox.io\/embed\/react-zoom-rotate-kx8jdl?fontsize=14&#038;hidenavigation=1&#038;theme=dark\"\n     style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\"\n     title=\"react-zoom-rotate\"\n     allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n     sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n   ><\/iframe>\n<h2>Prerequisites<\/h2>\n<p>In order to get started with performing React image zoom in zoom out as well as how to do a rotate image in React, you\u2019ll need the following:<\/p>\n<ul>\n<li>Experience with JavaScript and React.js.<\/li>\n<li>Installing Node.js.<\/li>\n<li>For the simplest approach, plus a suite of additional image transformation features, you can use Cloudinary for free. If you don\u2019t already have an account, <a href=\"https:\/\/cloudinary.com\/users\/register\/free\">sign up for Cloudinary for free now<\/a>.<\/li>\n<\/ul>\n<h2>Setups and Installations<\/h2>\n<p>We\u2019ll run the following command in the terminal to create a new React.js application:<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">npx create-react-app zoom-rotate-app\n<\/code><\/span><\/pre>\n<p>The above command bootstraps a React application in ****the zoom-rotate folder.<\/p>\n<p>Next, we\u2019ll navigate to the project directory and install some dependencies:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\">cd zoom-rotate <span class=\"hljs-comment\"># to navigate into the project directory<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Navigate to the <code>src<\/code> directory and delete all the files except <code>App.js<\/code> and <code>index.js<\/code>.<\/p>\n<p>Next, we\u2019ll install the following npm packages:<\/p>\n<ul>\n<li>\n<a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">react-image-zo<\/a><a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">o<\/a><a href=\"https:\/\/www.npmjs.com\/package\/react-image-zooom\">om<\/a>, so we can access the zoom component in a React environment.<\/li>\n<li>\n<a href=\"https:\/\/www.npmjs.com\/package\/@cloudinary\/url-gen\">@cloudinary\/url-gen<\/a> to add Cloudinary transformations and generate a URL.<\/li>\n<li>\n<a href=\"https:\/\/www.npmjs.com\/package\/react-icons\">react-icons<\/a> to give us access to icons for rotating our image.<\/li>\n<\/ul>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">install<\/span> <span class=\"hljs-selector-tag\">react-image-zooom<\/span> <span class=\"hljs-keyword\">@cloudinary<\/span>\/url-gen react-icons\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>or<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">yarn<\/span> <span class=\"hljs-selector-tag\">add<\/span> <span class=\"hljs-selector-tag\">react-image-zooom<\/span> <span class=\"hljs-keyword\">@cloudinary<\/span>\/url-gen react-icons\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Next, we\u2019ll install the <a href=\"https:\/\/react-bootstrap.github.io\/getting-started\/introduction\">bootstrap library<\/a> with the following command to handle our styles.<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">npm install react-bootstrap bootstrap\n<\/code><\/span><\/pre>\n<p>Next, we\u2019ll <a href=\"https:\/\/cloudinary.com\/users\/login\">log in<\/a> to Cloudinary, navigate to the <strong>Samples folder<\/strong>, navigate to <strong>People<\/strong>, and tag a few images.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_1B67DFCE5E56B2603B8C1BD4D6B00900EA59FCCE2BB0A4C32137BD7A1DB4BC3B_1654491348899_Screenshot+2022-06-06+at+5.49.00+AM.png\" alt=\"Image showing screen shot of Cloudinary image gallery. Images are being selected to perform react image zoom and rotate image react to photos of jazz festival and happy chef\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1409\" height=\"707\"\/><\/p>\n<p>Create a tag name and click the <strong>Update<\/strong> button.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_1B67DFCE5E56B2603B8C1BD4D6B00900EA59FCCE2BB0A4C32137BD7A1DB4BC3B_1654491410223_Screenshot+2022-06-06+at+5.52.37+AM.png\" alt=\"Image showing screen shot of Cloudinary image tagging\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1409\" height=\"707\"\/><\/p>\n<p>Next, we\u2019ll provide our details in this URL format and query it to get our Cloudinary tagged assets:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\">https:\/\/res.cloudinary.com\/<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">cloud-name<\/span>&gt;<\/span>\/<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">type<\/span>&gt;<\/span>\/list\/<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">tag-name<\/span>&gt;<\/span>.json\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Next, we\u2019ll remove restrictions on <strong>Image list<\/strong> in Cloudinary. Navigate to <strong>Settings<\/strong> (the gear icon), click the <strong>Security<\/strong> tab and uncheck <code>Resource List<\/code> under Restricted media types.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_58974A82C712B8256B2283DFAF29E2CA8F3A4146DE75F175E6222C97F61C5844_1656955070045_Screenshot+2022-07-04+at+18.16.37.png\" alt=\"Image showing screen shot of Cloudinary image settings\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"2000\" height=\"833\"\/><\/p>\n<p>Scroll down to save your settings.<\/p>\n<p>Next, import the following line of code inside the <code>pages\/index.js<\/code> file:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"bootstrap\/dist\/css\/bootstrap.min.css\"<\/span>;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Your <code>index.js<\/code> should look like this:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-comment\">\/\/index.js<\/span>\n<span class=\"hljs-keyword\">import<\/span> React <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'react'<\/span>;\n<span class=\"hljs-keyword\">import<\/span> ReactDOM <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'react-dom\/client'<\/span>;\n<span class=\"hljs-keyword\">import<\/span> App <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'.\/App'<\/span>;\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\"bootstrap\/dist\/css\/bootstrap.min.css\"<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> root = ReactDOM.createRoot(<span class=\"hljs-built_in\">document<\/span>.getElementById(<span class=\"hljs-string\">'root'<\/span>));\n  root.render(\n    <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">React.StrictMode<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">App<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">React.StrictMode<\/span>&gt;<\/span><\/span>\n  );\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<h2>Building the Zoom Effect<\/h2>\n<p>Now, clean up the <code>App.js<\/code> file and update it with the following lines of code :<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\".\/App.css\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> ImageZoom <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react-image-zooom\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { useState, useEffect } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react\"<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> App = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n  <span class=\"hljs-keyword\">const<\/span> &#91;imageData, setImageData] = useState(<span class=\"hljs-literal\">null<\/span>);\n    \n  <span class=\"hljs-keyword\">const<\/span> baseURL = <span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/&lt;cloud-name&gt;\/image\"<\/span>;\n    \n  <span class=\"hljs-keyword\">const<\/span> getImages = <span class=\"hljs-keyword\">async<\/span> () =&gt; {\n    <span class=\"hljs-keyword\">const<\/span> res = <span class=\"hljs-keyword\">await<\/span> fetch(\n      <span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/&lt;cloud-name&gt;\/image\/list\/&lt;tag-name&gt;.json\"<\/span>\n    );\n  <span class=\"hljs-keyword\">const<\/span> data = <span class=\"hljs-keyword\">await<\/span> res.json();\n    setImageData(data);\n  };\n    \n    \n<span class=\"hljs-keyword\">return<\/span> (\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>ZOOM and Roatate Images in React.js<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"gallery\"<\/span>&gt;<\/span>\n      {imageData &amp;&amp;\n        imageData.resources.map((item) =&gt; {\n          const { format, public_id, version, type } = item;\n          return (\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">key<\/span>=<span class=\"hljs-string\">{version}<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"gallery-img\"<\/span>&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ImageZoom<\/span>\n                <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">{<\/span>`${<span class=\"hljs-attr\">baseURL<\/span>}\/${<span class=\"hljs-attr\">type<\/span>}\/<span class=\"hljs-attr\">v<\/span>${<span class=\"hljs-attr\">version<\/span>}\/${<span class=\"hljs-attr\">public_id<\/span>}<span class=\"hljs-attr\">.<\/span>${<span class=\"hljs-attr\">format<\/span>}`}\n                <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"Zoom-images\"<\/span>\n                <span class=\"hljs-attr\">zoom<\/span>=<span class=\"hljs-string\">\"300\"<\/span>\n              \/&gt;<\/span>\n            <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n          );\n        })}\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span><\/span>\n);\n};\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> App;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the snippets above, we:<\/p>\n<ul>\n<li>Imported <code>ImageZoom<\/code> from \u201creact-image-zooom\u201d and useState and useEffect from \u201creact\u201d.<\/li>\n<li>Created <code>imageData<\/code> state constant with useState hook and created a <strong>baseURL<\/strong> constant.<\/li>\n<li>Created the <code>getImages()<\/code> function to fetch the tagged assets from Cloudinary and update the imageData state.<\/li>\n<li>Looped through the <code>imageData<\/code>, generated a URL for the images, and used the <code>ImageZoom<\/code> component and displayed them.<\/li>\n<\/ul>\n<p>We would see our images rendered with zoom-in and zoom-out functionalities in the browser.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_1B67DFCE5E56B2603B8C1BD4D6B00900EA59FCCE2BB0A4C32137BD7A1DB4BC3B_1654523525272_zoomEffect.gif\" alt=\"Image showing GIF of sample images showing jazz festival and chef with react image zoom in zoom out applied\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1080\" height=\"608\"\/><\/p>\n<h2>Building the Rotate Effect<\/h2>\n<p>First, let\u2019s head to the Cloudinary Media Library, double-click any image asset, and copy the image directory.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_1B67DFCE5E56B2603B8C1BD4D6B00900EA59FCCE2BB0A4C32137BD7A1DB4BC3B_1654522327672_Screenshot+2022-06-06+at+2.27.07+PM.png\" alt=\"Image showing screen shot of Cloudinary image directory, picture of happy boy in a snowsuit which will undergo rotate image react\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1440\" height=\"787\"\/><\/p>\n<p>Next, update the <code>App.js<\/code> with the following snippets:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-comment\">\/\/App.js<\/span>\n...\nimport { Cloudinary } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"@cloudinary\/url-gen\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { byAngle } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"@cloudinary\/url-gen\/actions\/rotate\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { BsArrowClockwise, BsArrowCounterclockwise } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react-icons\/bs\"<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> App = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n    ...\n  const &#91;imageURL, setImageURL] = useState();\n  <span class=\"hljs-keyword\">const<\/span> &#91;rotateValue, setRotateValue] = useState(<span class=\"hljs-number\">0<\/span>);\n      \n  <span class=\"hljs-keyword\">const<\/span> rotateImages = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n    <span class=\"hljs-keyword\">const<\/span> cld = <span class=\"hljs-keyword\">new<\/span> Cloudinary({\n      <span class=\"hljs-attr\">cloud<\/span>: {\n        <span class=\"hljs-attr\">cloudName<\/span>: <span class=\"hljs-string\">\"cloud-name\"<\/span>,\n      },\n    });\n    <span class=\"hljs-keyword\">const<\/span> rotateImg = cld\n      .image(<span class=\"hljs-string\">\"image directory here\"<\/span>)\n      .rotate(byAngle(rotateValue));\n      setImageURL(rotateImg.toURL());\n    };\n    \n  ...\n    \nuseEffect(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n    ...\n  rotateImages();\n});\n\n<span class=\"hljs-keyword\">return<\/span> (\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Zoom and Roatate Images in React.js<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"gallery\"<\/span>&gt;<\/span>\n         ...\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    \n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"rotate\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">{imageURL}<\/span> <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"snow-boy\"<\/span> <span class=\"hljs-attr\">width<\/span>=<span class=\"hljs-string\">{500}<\/span> <span class=\"hljs-attr\">height<\/span>=<span class=\"hljs-string\">{500}<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"controls m-3\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span>\n            <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{()<\/span> =&gt;<\/span> setRotateValue(rotateValue - 90)}\n            className=\"m-1 btn-primary\"\n          &gt;\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">BsArrowCounterclockwise<\/span> \/&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span>\n            <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{()<\/span> =&gt;<\/span> setRotateValue(rotateValue + 90)}\n            className=\"m-1 btn-primary\"\n          &gt;\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">BsArrowClockwise<\/span> \/&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span><\/span>\n  );\n};\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> App;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the snippets above, we:<\/p>\n<ul>\n<li>Imported Cloudinary and <code>byAngle<\/code> rotate actions from \u201c@cloudinary\/url-gen.\u201d<\/li>\n<li>Imported Clockwise and CounterClockwise arrows from react-icons and created <code>imageURL<\/code> and <code>rotateValue<\/code> state constants.<\/li>\n<li>Created the <code>rotateImages()<\/code> function and inside it, started a new instance of Cloudinary, and passed our cloud name.<\/li>\n<li>Created the <code>rotateImg<\/code> constant, targeted our image asset, called the <code>rotate()<\/code> and <code>byAngle()<\/code> functions on it. Then, we passed the <code>rotateValue<\/code> state and updated the <code>imageURL<\/code> state.<\/li>\n<li>Rendered the <code>imageURL<\/code> in an img tag and rendered the Counterclockwise and Clockwise arrows with an <code>onClick()<\/code> function that will decrease or increase the <code>rotateValue<\/code> state.<\/li>\n<\/ul>\n<p>Your <code>App.js<\/code> should look like this:<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-comment\">\/\/App.js<\/span>\n<span class=\"hljs-keyword\">import<\/span> <span class=\"hljs-string\">\".\/styles.css\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> ImageZoom <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react-image-zooom\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { useState, useEffect } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { Cloudinary } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"@cloudinary\/url-gen\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { byAngle } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"@cloudinary\/url-gen\/actions\/rotate\"<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { BsArrowClockwise, BsArrowCounterclockwise } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">\"react-icons\/bs\"<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> App = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n  <span class=\"hljs-keyword\">const<\/span> &#91;imageData, setImageData] = useState(<span class=\"hljs-literal\">null<\/span>);\n  <span class=\"hljs-keyword\">const<\/span> &#91;imageURL, setImageURL] = useState();\n  <span class=\"hljs-keyword\">const<\/span> &#91;rotateValue, setRotateValue] = useState(<span class=\"hljs-number\">0<\/span>);\n  <span class=\"hljs-keyword\">const<\/span> rotateImages = <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n  <span class=\"hljs-keyword\">const<\/span> cld = <span class=\"hljs-keyword\">new<\/span> Cloudinary({\n    <span class=\"hljs-attr\">cloud<\/span>: {\n      <span class=\"hljs-attr\">cloudName<\/span>: <span class=\"hljs-string\">\"cloud-name\"<\/span>\n    }\n  });\n  \n  <span class=\"hljs-keyword\">const<\/span> rotateImg = cld\n    .image(<span class=\"hljs-string\">\"image directory here\"<\/span>)\n    .rotate(byAngle(rotateValue));\n    setImageURL(rotateImg.toURL());\n  };\n  \n  <span class=\"hljs-keyword\">const<\/span> baseURL = <span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/&lt;cloud-name&gt;\/image\"<\/span>;\n  <span class=\"hljs-keyword\">const<\/span> getImages = <span class=\"hljs-keyword\">async<\/span> () =&gt; {\n    <span class=\"hljs-keyword\">const<\/span> res = <span class=\"hljs-keyword\">await<\/span> fetch(\n      <span class=\"hljs-string\">\"https:\/\/res.cloudinary.com\/&lt;cloud-name&gt;\/image\/list\/&lt;tag-name&gt;.json\"<\/span>\n    );\n    <span class=\"hljs-keyword\">const<\/span> data = <span class=\"hljs-keyword\">await<\/span> res.json();\n    setImageData(data);\n  };\n\nuseEffect(<span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> {\n  getImages();\n  rotateImages();\n});\n  \n<span class=\"hljs-keyword\">return<\/span> (\n  <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"App\"<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Zoom and Rotate Images in React.js<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"gallery\"<\/span>&gt;<\/span>\n        {imageData &amp;&amp;\n          imageData.resources.map((item) =&gt; {\n            const { format, public_id, version, type } = item;\n            return (\n              <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">key<\/span>=<span class=\"hljs-string\">{version}<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"gallery-img\"<\/span>&gt;<\/span>\n                <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">ImageZoom<\/span>\n                  <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">{<\/span>`${<span class=\"hljs-attr\">baseURL<\/span>}\/${<span class=\"hljs-attr\">type<\/span>}\/<span class=\"hljs-attr\">v<\/span>${<span class=\"hljs-attr\">version<\/span>}\/${<span class=\"hljs-attr\">public_id<\/span>}<span class=\"hljs-attr\">.<\/span>${<span class=\"hljs-attr\">format<\/span>}`}\n                  <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"Zoom-images\"<\/span>\n                  <span class=\"hljs-attr\">zoom<\/span>=<span class=\"hljs-string\">\"300\"<\/span>\n                \/&gt;<\/span>\n              <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n            );\n          })}\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"rotate\"<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">{imageURL}<\/span> <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"snow-boy\"<\/span> <span class=\"hljs-attr\">width<\/span>=<span class=\"hljs-string\">{500}<\/span> <span class=\"hljs-attr\">height<\/span>=<span class=\"hljs-string\">{500}<\/span> \/&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span> <span class=\"hljs-attr\">className<\/span>=<span class=\"hljs-string\">\"controls m-3\"<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span>\n            <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{()<\/span> =&gt;<\/span> setRotateValue(rotateValue - 90)}\n            className=\"m-1 btn-primary\"\n          &gt;\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">BsArrowCounterclockwise<\/span> \/&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span>\n            <span class=\"hljs-attr\">onClick<\/span>=<span class=\"hljs-string\">{()<\/span> =&gt;<\/span> setRotateValue(rotateValue + 90)}\n            className=\"m-1 btn-primary\"\n            &gt;\n            <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">BsArrowClockwise<\/span> \/&gt;<\/span>\n          <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n        <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n      <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span><\/span>\n  );\n};\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> App;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>We\u2019ll have the zoom and rotate functionalities working on the images in the browser as expected.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cloudinary-marketing-res.cloudinary.com\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/media_jams\/s_1B67DFCE5E56B2603B8C1BD4D6B00900EA59FCCE2BB0A4C32137BD7A1DB4BC3B_1654523938753_rotateEffect.gif\" alt=\"Image showing gif example of react image zoom and rotate image react coding applied to photos of happy boy in a snowsuit, man playing saxophone and a cook posing at work\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1080\" height=\"608\"\/><\/p>\n<h2><strong>Using Native CSS for Image Rotation in React:<\/strong><\/h2>\n<p>To rotate an image directly in your React components without relying on Cloudinary, you can use the CSS <code>transform: rotate() <\/code>property. This is a simple yet effective way of rotating your images. Here\u2019s an example:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>img { transform: rotate(90deg); }\n<\/code><\/pre>\n<p>Additionally, you can specify the point around which the image should rotate using the transform-origin property:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>img { transform: rotate(90deg); transform-origin: top left; }\n<\/code><\/pre>\n<p>By default, the image rotates around its center. But with transform-origin, you can set it to other values like top left or bottom right.<\/p>\n<p>If you\u2019d like to add an animation effect to the rotation, utilize the transition property:<\/p>\n<pre class=\"js-syntax-highlighted\"><code>img { transform: rotate(90deg); transition: 1s; }\n<\/code><\/pre>\n<p>With this CSS snippet, your image will take one second to complete its rotation. It\u2019s a nifty trick to smoothen the visual effect of the rotation.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this post, we implemented zoom and rotating image functionalities using Cloudinary, React-image-zoom, and React. <a href=\"https:\/\/cloudinary.com\/users\/register_free\">Sign up for a free Cloudinary account<\/a> today to get started.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":87,"featured_media":30497,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,370,177,246],"class_list":["post-27864","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-image","tag-javascript","tag-react"],"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>Zoom and Rotate Image in React<\/title>\n<meta name=\"description\" content=\"In this post, you&#039;ll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.\" \/>\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\/zoom-and-rotate-image-in-reactjs\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Zoom and Rotate Image in ReactJS\" \/>\n<meta property=\"og:description\" content=\"In this post, you&#039;ll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-16T17:40:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"melindapham\" \/>\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\/zoom-and-rotate-image-in-reactjs#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\"},\"author\":{\"name\":\"melindapham\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9\"},\"headline\":\"Zoom and Rotate Image in ReactJS\",\"datePublished\":\"2023-07-24T14:00:00+00:00\",\"dateModified\":\"2025-10-16T17:40:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\"},\"wordCount\":6,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA\",\"keywords\":[\"Guest Post\",\"Image\",\"Javascript\",\"React\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2023\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\",\"url\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\",\"name\":\"Zoom and Rotate Image in React\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA\",\"datePublished\":\"2023-07-24T14:00:00+00:00\",\"dateModified\":\"2025-10-16T17:40:53+00:00\",\"description\":\"In this post, you'll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA\",\"width\":2000,\"height\":1100,\"caption\":\"Image showing graphic example of react image zoom and rotate image react coding applied to photo of man and boy fishing\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Zoom and Rotate Image in ReactJS\"}]},{\"@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\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9\",\"name\":\"melindapham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g\",\"caption\":\"melindapham\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Zoom and Rotate Image in React","description":"In this post, you'll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.","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\/zoom-and-rotate-image-in-reactjs","og_locale":"en_US","og_type":"article","og_title":"Zoom and Rotate Image in ReactJS","og_description":"In this post, you'll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.","og_url":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs","og_site_name":"Cloudinary Blog","article_published_time":"2023-07-24T14:00:00+00:00","article_modified_time":"2025-10-16T17:40:53+00:00","og_image":[{"width":2000,"height":1100,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","type":"image\/jpeg"}],"author":"melindapham","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs"},"author":{"name":"melindapham","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9"},"headline":"Zoom and Rotate Image in ReactJS","datePublished":"2023-07-24T14:00:00+00:00","dateModified":"2025-10-16T17:40:53+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs"},"wordCount":6,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","keywords":["Guest Post","Image","Javascript","React"],"inLanguage":"en-US","copyrightYear":"2023","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs","url":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs","name":"Zoom and Rotate Image in React","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","datePublished":"2023-07-24T14:00:00+00:00","dateModified":"2025-10-16T17:40:53+00:00","description":"In this post, you'll learn how to use React image zoom in zoom out as well as how to do a rotate image in React. You\u2019ll also discover how Cloudinary\u2019s free tool can help make image transformations even easier.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","width":2000,"height":1100,"caption":"Image showing graphic example of react image zoom and rotate image react coding applied to photo of man and boy fishing"},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/zoom-and-rotate-image-in-reactjs#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Zoom and Rotate Image in ReactJS"}]},{"@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":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/0d5ad601e4c3b5be89245dfb14be42d9","name":"melindapham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e6f989fa97fe94be61596259d8629c3df65aec4c7da5c0000f90d810f313d4f4?s=96&d=mm&r=g","caption":"melindapham"}}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1690223969\/Blog-Zoom_rotate_reactjs\/Blog-Zoom_rotate_reactjs.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/27864","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\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=27864"}],"version-history":[{"count":13,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/27864\/revisions"}],"predecessor-version":[{"id":38788,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/27864\/revisions\/38788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/30497"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=27864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=27864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=27864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}