{"id":3112,"date":"2013-01-29T14:12:48","date_gmt":"2013-01-29T13:12:48","guid":{"rendered":"http:\/\/flaven.fr\/?p=3112"},"modified":"2013-09-24T05:22:39","modified_gmt":"2013-09-24T03:22:39","slug":"mac-apple-applescript-photoshop-manipuler-photoshop-a-laide-de-applescript-pour-executer-des-actions-par-lot","status":"publish","type":"post","link":"https:\/\/flaven.fr\/2013\/01\/mac-apple-applescript-photoshop-manipuler-photoshop-a-laide-de-applescript-pour-executer-des-actions-par-lot\/","title":{"rendered":"Mac, Apple, AppleScript, Photoshop &#8211; Manipuler Photoshop \u00e0 l&#8217;aide de AppleScript pour ex\u00e9cuter des actions par lot"},"content":{"rendered":"<p><!--  Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot   --><br \/>\n<!--  Mac, Apple, AppleScript, Photoshop, automation, photoshop, action, adobe, Reference, Photoshop, Adobe, Developer, application, action, lot, photo, media  --><\/p>\n<p>On oublie trop souvent que sur Mac et avec les produits Adobe, on peut faciliter la gestion des contenus m\u00e9dias \u00e0 l&#8217;aide de script de traitement par lot.<!--more--> Dans cet article, on va voir comment utiliser un script, qui plus tard sera compil\u00e9 en <code>.app<\/code> pour effectuer des traitements en masse sur des images.<\/p>\n<h4>Enregistrer une action sous Photoshop<\/h4>\n<p>On va enregistrer un traitement simple sous Photoshop. Chaque photo sera diminu\u00e9 en taille \u00e0 20% puis lui appliquer le filtre &#8220;Solarize&#8221;, cela nous permettra de nous rendre compte facilement que les changements op\u00e9r\u00e9s par le script fonctionnent.<\/p>\n<p><i>Avant le traitement<\/i><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/img_before.jpg\" width=\"600\" height=\"450\" alt=\"Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot\"><\/p>\n<p><i>Apr\u00e8s le traitement<\/i><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/img_after.jpg\" width=\"307\" height=\"230\" alt=\"Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot\"><\/p>\n<h4>Utiliser le script<\/h4>\n<p>Voici le code du script, nous allons pointer vers l&#8217;action <code>save_20_percent_solar<\/code> dans un r\u00e9pertoire d&#8217;actions nomm\u00e9 <code>hecube<\/code>. Attention, le nom de l&#8217;action comme celle du r\u00e9pertoire est sensible \u00e0 la casse.<\/p>\n<p><i>La ligne en question<\/i><\/p>\n<pre lang=\"applescript\">\r\ndo action \"save_20_percent_solar\" from \"hecube\"\r\n<\/pre>\n<p><i>Les commentaires en <code>AppleScript<\/code><\/i><br \/>\nPour information, les commentaires en <code>AppleScript<\/code> s&#8217;\u00e9crivent de cette mani\u00e8re <code>(* Ceci est un commentaire en AppleScript *)<\/code> ou de la sorte <code>--- Ceci est un commentaire en AppleScript<\/code><\/p>\n<p><b>L&#8217;action qui va \u00eatre ex\u00e9cut\u00e9 par Photoshop \u00e0 l&#8217;aide du script<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/applescript_automation_script_1.jpg\" width=\"500\" height=\"265\" alt=\"Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot\"><\/p>\n<p><b>Le code dans l&#8217;\u00e9diteur AppleScript de Mac<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/applescript_automation_script_3.jpg\" width=\"500\" height=\"265\" alt=\"Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot\"><\/p>\n<p><b>L&#8217;export au format <code>.app<\/code> du script<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/applescript_automation_script_4.jpg\" width=\"500\" height=\"265\" alt=\"Mac, Apple, AppleScript, Photoshop - Manipuler Photoshop \u00e0 l'aide de AppleScript pour ex\u00e9cuter des actions par lot\"><\/p>\n<h4>Le script dans sa totalit\u00e9<\/h4>\n<p>Voici la source compl\u00e8te du script.<\/p>\n<pre lang=\"applescript\">\r\n\t\r\n\t(*\r\n\tThis the version to handle action in photoshop for a bunch of jpg\r\n\tFrom http:\/\/social.hecube.net\/\r\n\t*)\r\n\r\n\t(*\r\n\r\n\tHere is the list of voices available on mac:\r\n\t* Agnes - female voice\r\n\t* Albert - male voice\r\n\t* Bad News - singing funereal voice\r\n\t* Bahh - an old male voice\r\n\t* Bells - singing, ringing bell effect voice\r\n\t* Boing - a springy effect voice\r\n\t* Bruce - male voice\r\n\t* Bubbles - bubble effect voice\r\n\t* Cellos - singing voice\r\n\t* Deranged - a nervous voice\r\n\t* Fred - male voice\r\n\t* Hysterical - laughing voice\r\n\t* Junior - young boy's voice\r\n\t* Kathy - female voice\r\n\t* Pipe Organ - singing organ effects voice\r\n\t* Princess - young girl's voice\r\n\t* Ralph - deep male voice\r\n\t* Trinoids - alien voice\r\n\t* Victoria - female voice\r\n\t* Whisper - whispering voice\r\n\t* Zarvox - alien voice\r\n\t*)\r\n\r\n\r\n\r\n\t-- This chooses the master folder where all your sub folders with images are stored\r\n\t-- Choose your Master Folder for this batch job\r\n\t-- using \"Fred\"\r\n\tsay \"Choose your Master Folder for this batch job\" using \"Victoria\"\r\n\tset raw_folder to choose folder\r\n\r\n\t-- This chooses the destination folder where all your result images are stored\r\n\t-- using \"Albert\"\r\n\tsay \"Choose your destination Folder for the processed files\" using \"Victoria\"\r\n\tset live_folder to choose folder\r\n\r\n\t-- This checks when the batch started and stores the date value\r\n\tset startTime to time of (current date)\r\n\r\n\t-- This the file counter\r\n\tset fileCounter to 0\r\n\r\n\r\n\t\ttell application \"Finder\"\r\n\t\t\tset itemList to files in raw_folder\r\n\t\tend tell\r\n\r\n\t\trepeat with j from 1 to (number of itemList)\r\n\t\tset fileCounter to fileCounter + 1\r\n\t\tend repeat\r\n\r\n\t\trepeat with an_item in itemList\r\n\t\t\ttell application \"Finder\"\r\n\t\t\t\tset current to an_item as alias\r\n\t\t\tend tell\r\n\r\n\t\t\ttell application \"Adobe Photoshop CS4\"\r\n\t\t\t\tactivate\r\n\t\t\t\topen current\r\n\t\t\t\tset this_image to current document\r\n\r\n\t\t\t\t(*  \r\n\t\t\t\tChoose your action \"save_20_percent_solar\" in actions directory \"hecube\"\r\n\t\t\t\tCareful this case sensitive\r\n\t\t\t\t *)\r\n\t\t\t\tdo action \"save_20_percent_solar\" from \"hecube\"\r\n\r\n\r\n\t\t\t\ttell current document\r\n\t\t\t\t\tsave as JPEG in live_folder\r\n\t\t\t\t\tclose\r\n\t\t\t\tend tell\r\n\t\t\tend tell\r\n\t\tend repeat\r\n\r\n\r\n\t\tset endTime to time of (current date)\r\n\r\n\t\t(* end *)\r\n\t\tsay \"The job is done, please have a look to the destination folder. The operation took  \" & endTime - startTime & \" seconds. The directory contains \" & fileCounter & \" files.\" using \"Victoria\"\r\n\r\n\t\t(* Dialog box if needed *)\r\n\t\t(* \r\n\t\tdisplay dialog \"nThe operation took  \" & endTime - startTime & \" seconds\" & \".nThe directory contains \" & fileCounter & \" files.n\"\r\n\t\t*)\r\n<\/pre>\n<h2>En savoir plus<\/h2>\n<ul>\n<li>Adobe Photoshop Scripting<br \/>\n\t<a href=\"http:\/\/www.adobe.com\/devnet\/photoshop\/scripting.html\" target=\"_blank\">http:\/\/www.adobe.com\/devnet\/photoshop\/scripting.html<\/a><\/li>\n<li>Introduction to AppleScript Overview<br \/>\n\t<a href=\"https:\/\/developer.apple.com\/library\/mac\/#documentation\/AppleScript\/Conceptual\/AppleScriptX\/AppleScriptX.html\" target=\"_blank\">https:\/\/developer.apple.com\/library\/mac\/#documentation\/AppleScript\/Conceptual\/AppleScriptX\/AppleScriptX.html<\/a><\/li>\n<li>Automation sur mac.tutsplus.com<br \/>\n\t<a href=\"http:\/\/mac.tutsplus.com\/category\/tutorials\/automation\/\" target=\"_blank\">http:\/\/mac.tutsplus.com\/category\/tutorials\/automation\/<\/a><\/li>\n<li>17 AppleScripts You Should Try<br \/>\n\t<a href=\"http:\/\/www.maclife.com\/article\/howtos\/17_applescripts_you_should_try\" target=\"_blank\">http:\/\/www.maclife.com\/article\/howtos\/17_applescripts_you_should_try<\/a><\/li>\n<li>Introduction to Scripting Photoshop<br \/>\n\t<a href=\"\thttp:\/\/www.mactech.com\/articles\/mactech\/Vol.22\/22.08\/ScriptingPhotoshop\/index.html\" target=\"_blank\">\thttp:\/\/www.mactech.com\/articles\/mactech\/Vol.22\/22.08\/ScriptingPhotoshop\/index.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>On oublie trop souvent que sur Mac et avec les produits Adobe, on peut faciliter la gestion des contenus m\u00e9dias \u00e0 l&#8217;aide de script de&hellip; <\/p>\n<p class=\"text-center\"><a href=\"https:\/\/flaven.fr\/2013\/01\/mac-apple-applescript-photoshop-manipuler-photoshop-a-laide-de-applescript-pour-executer-des-actions-par-lot\/\" class=\"more-link\">Continue reading &rarr; <span class=\"screen-reader-text\">Mac, Apple, AppleScript, Photoshop &#8211; Manipuler Photoshop \u00e0 l&#8217;aide de AppleScript pour ex\u00e9cuter des actions par lot<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9385,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"bf_ai_meta_description":"Automatisez Photoshop sur Mac avec AppleScript pour des actions par lot. Traitez des images en masse, r\u00e9duisez la taille et appliquez des filtres.","bf_ai_og_title":"Automatiser Photoshop avec AppleScript","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3444,3445,3447,3448,3449,3451,3435],"tags":[502,299,223,503,163,504,505,506,2210,337,2240,155,507],"class_list":["post-3112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-databases","category-seo-web-marketing","category-technology-trends","category-tools-productivity","category-tutorials-how-to","category-web-design-front-end","category-web-development","tag-action","tag-adobe","tag-apple","tag-applescript","tag-application","tag-automation","tag-developer","tag-lot","tag-mac","tag-media","tag-photo","tag-photoshop","tag-reference"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3Vuhl-Oc","jetpack_featured_media_url":"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/01\/applescript_automation_script_b_bf.jpg","_links":{"self":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/3112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/comments?post=3112"}],"version-history":[{"count":1,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/3112\/revisions"}],"predecessor-version":[{"id":9386,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/3112\/revisions\/9386"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media\/9385"}],"wp:attachment":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media?parent=3112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/categories?post=3112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/tags?post=3112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}