{"id":33,"date":"2009-12-04T11:40:36","date_gmt":"2009-12-04T10:40:36","guid":{"rendered":"http:\/\/unckel.com\/blog\/?p=33"},"modified":"2019-12-07T22:09:19","modified_gmt":"2019-12-07T21:09:19","slug":"photoshop-script-mehrere-bilder-auf-gemeinsame-breite-skalieren","status":"publish","type":"post","link":"https:\/\/unckel.de\/blog\/photoshop-script-mehrere-bilder-auf-gemeinsame-breite-skalieren\/","title":{"rendered":"Photoshop Script: Mehrere Bilder auf gemeinsame Breite skalieren"},"content":{"rendered":"<p>Skaliert alle ge\u00f6ffneten Bilder im Photoshop auf einen vorgegebene gemeinsame Breite.<\/p>\n<p>Beispiel: Will man mehrere unterschiedlich formatierte (breit- und hochformatige) Bilder auf einer Website platzieren und hat dazu 900 Pixel in der Breite, kann dieses Script alle Bilder auf eine gemeinsame H\u00f6he und der gegebenen Breite skalieren.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-35\" src=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/photoshoparragnepics.jpg\" alt=\"\" width=\"403\" height=\"404\" srcset=\"https:\/\/unckel.de\/blog\/wp-content\/uploads\/photoshoparragnepics.jpg 403w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/photoshoparragnepics-200x200.jpg 200w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/photoshoparragnepics-400x400.jpg 400w, https:\/\/unckel.de\/blog\/wp-content\/uploads\/photoshoparragnepics-100x100.jpg 100w\" sizes=\"auto, (max-width: 403px) 100vw, 403px\" \/><\/p>\n<pre>\/\/####################################################################\n\/\/\n\/\/  Arrange \/ resize images (same height) to a given total width\n\/\/  Photoshop Script (CS2, tested on PC) \n\/\/\n\/\/####################################################################\n\n\/\/ save the current preferences &amp; settings\nvar startRulerUnits = app.preferences.rulerUnits\nvar startTypeUnits = app.preferences.typeUnits\nvar startDisplayDialogs = app.displayDialogs\napp.preferences.rulerUnits = Units.PIXELS\napp.preferences.typeUnits = TypeUnits.PIXELS\napp.displayDialogs = DialogModes.NO\n\n\/\/ main script\nvar docs = app.documents;\nvar openDocs = docs.length;\n\nvar totalWidth = prompt('Total available width:', '500');\nvar spareWidth = prompt('Gap between pictures:', '0');\nvar totalSpare = spareWidth * (openDocs-1);\ntotalWidth = totalWidth - totalSpare;\n\n\/\/ get height of all images and store in array\nvar imgSize = new Array();\n\nfor (var i=0; i&lt;openDocs; i++) {\n\tapp.activeDocument = docs[i];\n\timgSize[i] = new ent(i, app.activeDocument.height);\n}\n\n\/\/ sort 2-dim. array  -&gt; http:\/\/www.webmasterbiz.de\/showthread.php?t=618\nimgSize.sort(cmpnum);\n\nvar smallestCommonHeight = imgSize[0].height;\nvar totalOriginalWidth = 0;\n\n\/\/ all images resize to smallestCommonHeight\nfor (var i=0; i&lt;openDocs; i++) {\n\tapp.activeDocument = docs[i];\n\tapp.activeDocument.resizeImage(null, smallestCommonHeight, null, ResampleMethod.BICUBIC)\n\ttotalOriginalWidth = totalOriginalWidth + app.activeDocument.width;\n}\n\nvar summary = \"Summary:\\n\";\nvar resizeValue = totalWidth \/ totalOriginalWidth;\n\n\/\/ all images resize to the right width\nfor (var i=0; i&lt;openDocs; i++) {\n\tapp.activeDocument = docs[i];\n\tvar newWidth = app.activeDocument.width * resizeValue;\n\tapp.activeDocument.resizeImage(newWidth, null, null, ResampleMethod.BICUBIC)\n\tsummary = summary + app.activeDocument.name + \": \" + \n\t\t\t\t\t\tapp.activeDocument.width + \" \/ \" + \n\t\t\t\t\t\tapp.activeDocument.height + \"\\n\";\n}\n\n\/\/ restore settings\napp.preferences.rulerUnits = startRulerUnits;\napp.preferences.typeUnits = startTypeUnits;\napp.displayDialogs = startDisplayDialogs;\n\n\/\/ finish!\nalert(summary);\n\n\/\/ array -&gt; http:\/\/www.webmasterbiz.de\/showthread.php?t=618\nfunction ent(imgnr, height) {\n    this.imgnr = imgnr;\n\tthis.height = height;\n}\n\n\/\/ sort array by height\nfunction cmpnum(inp1, inp2) {\n    return inp1.height - inp2.height;\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Skaliert alle ge\u00f6ffneten Bilder im Photoshop auf einen vorgegebene gemeinsame Breite. Beispiel: Will man mehrere unterschiedlich formatierte (breit- und hochformatige) Bilder auf einer Website platzieren und hat dazu 900 Pixel in der Breite, kann dieses Script alle Bilder auf eine gemeinsame H\u00f6he und der gegebenen Breite skalieren. \/\/#################################################################### \/\/ \/\/ Arrange \/ resize images (same [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-adobe-photoshop"],"_links":{"self":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":798,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions\/798"}],"wp:attachment":[{"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unckel.de\/blog\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}