Powershell with Image Magick Montage reading from text file


I am working on a PowerShell script using Image Magick's montage function. My script works until the source files (.jpgs) volume increases to an ambiguous number of files. Once there are 'too many' files, the script fails due to 'Program 'montage.exe' failed to run: The filename or extension is too long'. It was suggested on the Image Magick forum (link @ bottom) to have PowerShell read from a text doc instead to reduce the length using the '@' operator.

The code now looks like:

montage -verbose -label %t -pointsize 25 -background '#FFFFFF' -tile 24x5 -fill 'black' -define jpeg:size=600x780 -geometry 600x780+40+150 -quality 90 -auto-orient @E:\Output\contactSheetImages.txt E:\Contact_Sheet.jpg

I am getting the following errors:

montage : montage.exe: unable to open image '@E:ÿþE': No such file or directory @ error/blob.c/OpenBlob/2695. montage.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/508. montage.exe: `E:\Contact_Sheet.jpg' @ error/montage.c/MontageImageCommand/1774.

I am fairly certain using the '@' operator as I have may be confusing the script, but I don't have enough understanding of using '@' in PowerShell to know why.

Can anyone with ImageMagick understanding, or simply a stronger PowerShell understanding explain why that may be breaking the script?

I have tried:

<ul><li>Replacing @E:\Output\contactSheetImages.txt with a variable to Get-Content from the txt file</li> <li>Targeting the text doc without the '@' operator</li> <li>Using single and double quotes around @E:\Output\contactSheetImages.txt</li> </ul>

Image Magick Forum: <a href="https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=34596" rel="nofollow">https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=34596</a>


Thanks everyone for your ideas and help. While I wasn't able to use any of the provided ideas it allowed me to think up a simple solution.

I simply removed the need to read a text file by targeting the files directly:

montage -verbose -label %t -pointsize 25 -background '#FFFFFF' -tile 24x5 -fill 'black' -define jpeg:size=600x780 -geometry 600x780+40+150 -quality 90 -auto-orient E:\Output\*.jpg E:\Contact_Sheet.jpg

Although I would have liked to solve the problem instead of developing a work around, my script is now working.


  • Adjust the font size to fit for several UIButton's so that they all have the same font size
  • Morris chart with dynamic data
  • Google chart ChartWrapper getting invalid column index
  • Drawing Isometric Tilemaps
  • How to cast UInt to SInt value in Chisel3?
  • OpenLayers: How to re-align mouse coordinates and vector layers after fluid css rendering of map div
  • C#: How To Crosshatch A Bar In An ASP.Net Bar Chart
  • Return multidimensional vector from function for use in main, how to use correctly?
  • How to get an extra column in relational model in Django-rest-framework serializer?
  • Specify datetime format for WCF Data Service
  • How can I export a gbm model in R?
  • Set theory data structure
  • Controlling volume of running applications in Mac OS X via Objective-C
  • Matlab: creating a (k+1)-tensor from a list of k-tensors
  • How to read the param value from the object tag using javascript
  • Dropdown menu items hides behind main menu in bootstrap customized navigation bar
  • Entity Framework Core 2.0 add-migration not generating anything
  • Imagemagick set interline spacing?
  • 'Enemy' was not declared in this scope?
  • C++ Armadillo Access Triangular Matrix Elements
  • xcode don't localize specific strings
  • Swift: Switch statement fallthrough behavior
  • How to attach a node.js readable stream to a Sendgrid email?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Google Custom Search with transparent background
  • Android fill_parent issue
  • Repeat a vertical line on every page in Report Builder / SSRS
  • java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions
  • MySQL WHERE-condition in procedure ignored
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • JSON with duplicate key names losing information when parsed
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Web-crawler for facebook in python
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • trying to dynamically update Highchart column chart but series undefined
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • How to Embed XSL into XML
  • java string with new operator and a literal