Module Scope / Binary Files

This topic contains 1 reply, has 2 voices, and was last updated by  Olaf Soyk 3 months, 2 weeks ago.

  • Author
  • #93058

    John Carney

    I am building a simple module to resize JPG images into thumbnails suitable for Active Directory / GAL. It's based around ImageMagick, basically just a wrapper function for convert.exe file and a few parameters.

    My question is, within the function code, how would I specify the path to convert.exe. It lives in the module folder, but this isn't where the function will be invoked, so a relative path isn't applicable. At the moment it is hardcoded as follows:

    function Resize-GALImage {
    #blah blah, parameters etc.
        foreach ($Item in $Items)
            Write-Verbose "Converting $($Item.FullName)"
            # Todo: fix hard-coded path to convert.exe
            C:\Scripts\GALPhotos\bin\convert.exe -quality $Quality -depth 8 -thumbnail "$($Zoom)x$($Zoom)^" -gravity North -crop $Crop $Item.FullName "$($FullOutputFolderPath)\$($Item.BaseName).jpg"

    What should appear instead of "C:\Scripts\GALPhotos\bin\" ? Is there some good documentation on use of binary files within modules?


  • #93094

    Olaf Soyk

    You could try $PSScriptRoot or $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition. It might not be the complete ready to use path but if you play around with it a little you will be able to transform it to your needs. 😉

You must be logged in to reply to this topic.