Powershell with Image Magick Montage reading from text file

为君一笑 提交于 2019-12-13 03:48:40

问题


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:

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

Image Magick Forum: https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=34596


回答1:


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.



来源:https://stackoverflow.com/questions/51936992/powershell-with-image-magick-montage-reading-from-text-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!