{"id":45,"date":"2026-02-09T11:45:01","date_gmt":"2026-02-09T03:45:01","guid":{"rendered":"https:\/\/openpyxl.com\/blog\/?p=45"},"modified":"2026-01-16T07:28:27","modified_gmt":"2026-01-16T07:28:27","slug":"how-to-symmetry-transformate-images-using-openpyxl","status":"publish","type":"post","link":"https:\/\/openpyxl.com\/blog\/how-to-symmetry-transformate-images-using-openpyxl.html","title":{"rendered":"How To Symmetry Transformate Images Using OpenPyXL?"},"content":{"rendered":"<h2>Method<\/h2>\n<p>img2=img.transpose(pilImage.FLIP_LEFT_RIGHT)\u00a0\u00a0\u00a0 #Horizontal symmetry<\/p>\n<p>#img2=img.transpose(pilImage.FLIP_TOP_BOTTOM)\u00a0\u00a0\u00a0 #Vertical symmetry<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Symmetry Transformation\n\nfrom openpyxl import Workbook\nfrom openpyxl.drawing.image import Image as xlImage\nfrom PIL import Image as pilImage\n\n#Create a workbook\nwb=Workbook()\n#Get the active worksheet\nws=wb.active\n\n# Open the original image file\nimg=pilImage.open('pic.jpg')\n\n#Apply a symmetry transformation\nimg2=img.transpose(pilImage.FLIP_LEFT_RIGHT)    #Horizontal symmetry\n#img2=img.transpose(pilImage.FLIP_TOP_BOTTOM)    #Vertical symmetry\n\n# Save the transformed image as a temporary file\npath='image4.jpg'\nimg2.save(path)\n\n# Add the image to the worksheet\nimg=xlImage(path)\nws.add_image(img, 'A1')\n\n# Save the workbook\nwb.save('image06.xlsx')\n\n# Delete the temporary file\nimport os\nos.remove(path)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"713\" src=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/02\/27.png\" alt=\"Symmetry Transformate Images Using OpenPyXL\" class=\"wp-image-305\" srcset=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/02\/27.png 872w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/02\/27-300x245.png 300w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/02\/27-768x628.png 768w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>OpenPyXL<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-openpyxl-picture"],"_links":{"self":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/comments?post=45"}],"version-history":[{"count":2,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/45\/revisions"}],"predecessor-version":[{"id":306,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/45\/revisions\/306"}],"wp:attachment":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/media?parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/categories?post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/tags?post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}