{"id":5549,"date":"2024-05-16T22:21:35","date_gmt":"2024-05-16T19:21:35","guid":{"rendered":"https:\/\/jani.penttinen.fi\/?post_type=notes&p=5549"},"modified":"2024-05-16T22:57:29","modified_gmt":"2024-05-16T19:57:29","slug":"automaattinen-tapa-yhdistaa-dronekuvat-monesta-alikansiosta-photoshopissa-script","status":"publish","type":"notes","link":"https:\/\/jani.penttinen.fi\/notes\/automaattinen-tapa-yhdistaa-dronekuvat-monesta-alikansiosta-photoshopissa-script\/","title":{"rendered":"Automaattinen tapa yhdist\u00e4\u00e4 dronekuvat monesta alikansiosta Photoshopissa (Script)"},"content":{"rendered":"\n
Jotkin Dronet tallentavat kuvat erillisiin alikansiohin kansioihin. Kuvien manuaalinen valitseminen ja yhdist\u00e4minen voi vied\u00e4 aikaa.<\/p>\n\n\n\n
Photoshop-skripti, joka automaattisesti k\u00e4y l\u00e4pi valitun kansion alakansiot ja yhdist\u00e4\u00e4 niist\u00e4 kuvat. T\u00e4m\u00e4 skripti k\u00e4ytt\u00e4\u00e4 Photomerge-toimintoa.<\/p>\n\n\n\n
.jsx<\/code>-muodossa.<\/li>\n\n\n\n- Siirr\u00e4 ladattu tiedosto suoraan Photoshopin
Presets\/Scripts<\/code> -kansioon.<\/li>\n\n\n\n- Scriptin pit\u00e4isi l\u00f6yty\u00e4 nyt kohdasta
File > Scripts<\/code><\/li>\n<\/ol>\n\n\n\n<\/div>\n\n\n\nSkripti<\/h2>\n\n\n\n
T\u00e4m\u00e4 Adobe Photoshop -skripti on suunniteltu automatisoimaan drone-kuvien yhdist\u00e4minen panoraamoiksi. Skripti k\u00e4y l\u00e4pi valitun kansion alakansiot, avaa kunkin kansion kuvat, yhdist\u00e4\u00e4 ne Photomerge-toiminnolla ja tallentaa tulokset valittuun kohdekansioon.<\/p>\n\n\n\n
Skriptin rakenne<\/h3>\n\n\n\n\n- Photomerge-skripti<\/strong>\n
\n- Sis\u00e4llytt\u00e4\u00e4 Photomerge.jsx ja siihen liittyv\u00e4t skriptit, jotta Photomerge-toiminto voidaan k\u00e4ytt\u00e4\u00e4.<\/li>\n<\/ul>\n<\/li>\n\n\n\n
- P\u00e4\u00e4toiminto<\/strong>\n
\nmain<\/code>: Hallitsee koko ty\u00f6nkulkua. N\u00e4ytt\u00e4\u00e4 asetusten valintadialogin, kutsuu kansioiden k\u00e4sittelytoiminnon ja ilmoittaa, kun kaikki panoramat on k\u00e4sitelty ja tallennettu.<\/li>\n<\/ul>\n<\/li>\n\n\n\n- K\u00e4ytt\u00f6liittym\u00e4asetukset<\/strong>\n
\nshowDialog<\/code>: N\u00e4ytt\u00e4\u00e4 k\u00e4ytt\u00e4j\u00e4lle dialogin, jossa voi valita l\u00e4hdekansion, kohdekansion, tiedostonimen etuliitteen ja yhdist\u00e4mistyypin. Palauttaa asetukset objektina, joka sis\u00e4lt\u00e4\u00e4 kaikki valinnat.<\/li>\n<\/ul>\n<\/li>\n\n\n\n- Kansioiden k\u00e4sittely<\/strong>\n
\nprocessFolders<\/code>: K\u00e4y l\u00e4pi valitun kansion alakansiot. Jos kansiossa on kuvatiedostoja, kutsuu funktiota, joka yhdist\u00e4\u00e4 kuvat panoraamaksi.<\/li>\n<\/ul>\n<\/li>\n\n\n\n- Panoraaman luominen<\/strong>\n
\ncreatePanorama<\/code>: Avaa kunkin kuvan, yhdist\u00e4\u00e4 ne Photomerge-toiminnolla ja tallentaa lopputuloksen JPEG-tiedostona valittuun kohdekansioon.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<\/div>\n\n\n\n\/\/ Include Photomerge.jsx and related scripts\nvar runphotomergeFromScript = true;\n\/\/@include \"Photomerge.jsx\"\n\n\/\/ Main function to control the workflow\nfunction main() {\n var settings = showDialog();\n if (settings) {\n var baseFolder = new Folder(settings.sourceFolder);\n var outputFolder = new Folder(settings.outputFolder);\n if (!outputFolder.exists) {\n outputFolder.create();\n }\n processFolders(baseFolder, outputFolder, settings);\n alert(\"All panoramas have been processed and saved successfully.\"); \n } else {\n alert(\"No settings returned from the dialog.\");\n }\n}\n\n\/\/ Show dialog to get user settings\nfunction showDialog() {\n var dialog = new Window(\"dialog\", \"Panorama Image Joiner || Beta 0.0001\");\n var instructions = \"Instructions:\\n\" +\n \"1. Select the folder where the panorama images are located. Each panorama's images should be in their own sub-folder.\\n\" +\n \"2. Select the folder where the panoramas will be saved.\\n\";\n dialog.add(\"statictext\", undefined, instructions, { multiline: true });\n\n var sourceFolderLabel = dialog.add(\"statictext\", undefined, \"Select Source Folder:\");\n var sourceInput = dialog.add(\"edittext\", undefined, \"\", { multiline: false });\n sourceInput.size = [180, 20];\n dialog.add(\"button\", undefined, \"Browse...\").onClick = function() {\n var selectedFolder = Folder.selectDialog(\"Select the source folder\");\n if (selectedFolder) sourceInput.text = selectedFolder.fsName;\n };\n\n var outputFolderLabel = dialog.add(\"statictext\", undefined, \"Select Output Folder:\");\n var outputInput = dialog.add(\"edittext\", undefined, \"\", { multiline: false });\n outputInput.size = [180, 20];\n dialog.add(\"button\", undefined, \"Browse...\").onClick = function() {\n var selectedFolder = Folder.selectDialog(\"Select the output folder\");\n if (selectedFolder) outputInput.text = selectedFolder.fsName;\n };\n\n var prefixLabel = dialog.add(\"statictext\", undefined, \"Enter Filename Prefix:\");\n var prefixInput = dialog.add(\"edittext\", undefined, \"PANO_\");\n prefixInput.size = [180, 20];\n\n \/\/ Merge type and additional options panel\n var mergeTypePanel = dialog.add(\"panel\", undefined, \"Merge Type:\");\n var autoRadio = mergeTypePanel.add(\"radiobutton\", undefined, \"Auto\");\n var prspRadio = mergeTypePanel.add(\"radiobutton\", undefined, \"Perspective\");\n var cylindricalRadio = mergeTypePanel.add(\"radiobutton\", undefined, \"Cylindrical\");\n var sphericalRadio = mergeTypePanel.add(\"radiobutton\", undefined, \"Spherical\");\n\n \/\/ Dialog buttons\n var buttonGroup = dialog.add(\"group\");\n buttonGroup.add(\"button\", undefined, \"OK\").onClick = function() {\n dialog.close(1);\n };\n buttonGroup.add(\"button\", undefined, \"Cancel\").onClick = function() {\n dialog.close(2);\n };\n\n if (dialog.show() === 1) {\n var mergeType = \"Auto\"; \/\/ Default to Auto\n if (prspRadio.value) mergeType = \"Prsp\";\n else if (cylindricalRadio.value) mergeType = \"cylindrical\";\n else if (sphericalRadio.value) mergeType = \"spherical\";\n\n return {\n sourceFolder: sourceInput.text,\n outputFolder: outputInput.text,\n mergeType: mergeType,\n prefix: prefixInput.text\n };\n }\n return null;\n}\n\n\n\/\/ Process each folder found in the base folder\nfunction processFolders(baseFolder, outputFolder, settings) {\n var folders = baseFolder.getFiles(function(f) { return f instanceof Folder; });\n for (var i = 0; i < folders.length; i++) {\n var folder = folders[i];\n var files = folder.getFiles(\/\\.(jpg|jpeg|tif|tiff|psd|png)$\/i);\n if (files.length > 0) {\n createPanorama(folder, files, outputFolder, settings);\n }\n }\n}\n\n\/\/ Create the panorama using the selected files and settings\nfunction createPanorama(sourceFolder, files, outputFolder, settings) {\n var initialDocs = app.documents.length; \n\n try {\n var fileArray = [];\n for (var i = 0; i < files.length; i++) {\n var file = files[i];\n fileArray.push(file);\n var openedFile = app.open(file);\n var openedDoc = app.activeDocument;\n openedDoc.selection.selectAll();\n openedDoc.selection.copy();\n if (i === 0) {\n app.documents.add(openedDoc.width, openedDoc.height);\n }\n app.activeDocument.paste();\n openedDoc.close(SaveOptions.DONOTSAVECHANGES);\n }\n\n if (fileArray.length > 0) {\n photomerge.alignmentKey = settings.mergeType;\n photomerge.advancedBlending = true;\n photomerge.lensCorrection = true;\n photomerge.removeVignette = true;\n photomerge.createPanorama(fileArray, false);\n } else {\n throw new Error(\"No images found to create the panorama.\");\n }\n\n var finalDoc = app.activeDocument;\n var filename = settings.prefix + sourceFolder.name + \".jpg\";\n var saveFile = new File(outputFolder + \"\/\" + filename);\n var saveOptions = new JPEGSaveOptions();\n saveOptions.quality = 12;\n finalDoc.saveAs(saveFile, saveOptions, true, Extension.LOWERCASE);\n\n } catch (e) {\n alert(\"An error occurred during the panorama creation: \" + e);\n } finally {\n while (app.documents.length > initialDocs) {\n app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);\n }\n }\n}\n\nmain();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Ongelma Jotkin Dronet tallentavat kuvat erillisiin alikansiohin kansioihin. Kuvien manuaalinen valitseminen ja yhdist\u00e4minen voi vied\u00e4 aikaa. Ratkaisu Photoshop-skripti, joka automaattisesti […]<\/p>\n","protected":false},"author":1,"featured_media":3112,"comment_status":"open","ping_status":"closed","template":"","acf":[],"yoast_head":"\n
Automaattinen tapa yhdist\u00e4\u00e4 dronekuvat monesta alikansiosta Photoshopissa (Script) – Jani Penttinen \u2013 Portfolio<\/title>\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\t\n