Thanks to Mr Bieber too for the explanations and for the triathlon image, 
I agree with it.

As already said, I would be grateful for any advice about getting any 
reference to the functions DoAction, Export, etc.

I am also wondering how, in the following code (source again : 
https://vsfxryan.com/portfolio/python-photoshop-action-scripts/), the 
programer can know that code "13" refers to PNG, etc. :

 #png save options
    options = 
win32com.client.Dispatch('Photoshop.ExportOptionsSaveForWeb')
    options.Format = 13   # PNG
    options.PNG8 = True  # Sets it to PNG-8 bit

Again, if these questions are too basic or the needed answers too 
elaborated, just forget it ; I have a lot to learn :)





De :    "Dennis Lee Bieber" <wlfr...@ix.netcom.com>
A :     python-win32@python.org
Date :  25.07.2019 18:43
Objet : Re: [python-win32] DoAction problem
Envoyé par :    "python-win32" 
<python-win32-bounces+sylvain.fejoz=ville-ge...@python.org>



On Thu, 25 Jul 2019 11:58:59 +0200, sylvain.fe...@ville-ge.ch declaimed 
the
following:

>
>My inspiration : 
>Web page explaining a Python code using pywin32 : 
>https://vsfxryan.com/portfolio/python-photoshop-action-scripts/, but I do 

>not want to define functions, I am too much beginner for this.
>

                 For someone "new to Python and coding" you are asking to 
compete in a
triathlon (invoking internal operations of an external program using
pywin32), and  without knowing how to shoot a gun (writing stand-alone
programs using basic operations). 

                 Defining functions is basic to any programming language, 
along with
looping and conditional branching.

>Problematic code :
>#run action script which opens the file, convert it to jpg, save and 
close 
>it.
>psApp.DoAction( actionScript, 'jpg_q8')
>
>Error message :
>NameError: name 'actionScript' is not defined
>

                 So did you really read the linked web page? 
"actionScript" is a
parameter passed into the example function.

-=-=-=-
 def edit_File( actionScript, imagePath, saveDir, psApp ):

                                 <SNIP>

    #run action script
    psApp.DoAction( actionScript, 'WaterMark')
    #save
    doc.Export(ExportIn=newSave, ExportAs=2, Options=options)
    return doc
-=-=-=-

                 See how it is the first parameter given to edit_File... 
Now, find where
edit_File is used and you find...

-=-=-=-
 def processFiles( files, saveDir, psApp ):
    for file in files:
        #determine what actionscript to run based off folder name (all
lower case)
        if 'btmleft' in file.lower():
            doc = edit_File( 'BtmLeft', file, saveDir, psApp )
        elif 'btmcenter' in file.lower():
            doc = edit_File( 'BtmCenter', file, saveDir, psApp )
        elif 'btmright' in file.lower():
            doc = edit_File( 'BtmRight', file, saveDir, psApp )
        #close image without saving
        doc.Close(2)
    # Close PSD without saving
    psApp.Quit()
-=-=-=-

                 See how the first argument given to edit_File is a STRING 
with the name
of the PS script to be invoked... Or as explained in the text of the web
page: 

"""Next, we run our action script, this is where the name of the action
script comes in handy. psApp.DoAction(“ScriptName”, “FolderName”) That is
how you run your action script. """


-- 
                 Wulfraed                 Dennis Lee Bieber         AF6VN
                 wlfr...@ix.netcom.com    
http://wlfraed.microdiversity.freeddns.org/

_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32



_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to