• <small id='9S5zU'></small><noframes id='9S5zU'>

      <tfoot id='9S5zU'></tfoot>

      <legend id='9S5zU'><style id='9S5zU'><dir id='9S5zU'><q id='9S5zU'></q></dir></style></legend>
    1. <i id='9S5zU'><tr id='9S5zU'><dt id='9S5zU'><q id='9S5zU'><span id='9S5zU'><b id='9S5zU'><form id='9S5zU'><ins id='9S5zU'></ins><ul id='9S5zU'></ul><sub id='9S5zU'></sub></form><legend id='9S5zU'></legend><bdo id='9S5zU'><pre id='9S5zU'><center id='9S5zU'></center></pre></bdo></b><th id='9S5zU'></th></span></q></dt></tr></i><div id='9S5zU'><tfoot id='9S5zU'></tfoot><dl id='9S5zU'><fieldset id='9S5zU'></fieldset></dl></div>

          <bdo id='9S5zU'></bdo><ul id='9S5zU'></ul>

        从 python 运行 imagemagick convert(控制台应用程序)

        时间:2023-09-03

              <tbody id='s4Dvg'></tbody>
              <legend id='s4Dvg'><style id='s4Dvg'><dir id='s4Dvg'><q id='s4Dvg'></q></dir></style></legend>
            1. <small id='s4Dvg'></small><noframes id='s4Dvg'>

              • <i id='s4Dvg'><tr id='s4Dvg'><dt id='s4Dvg'><q id='s4Dvg'><span id='s4Dvg'><b id='s4Dvg'><form id='s4Dvg'><ins id='s4Dvg'></ins><ul id='s4Dvg'></ul><sub id='s4Dvg'></sub></form><legend id='s4Dvg'></legend><bdo id='s4Dvg'><pre id='s4Dvg'><center id='s4Dvg'></center></pre></bdo></b><th id='s4Dvg'></th></span></q></dt></tr></i><div id='s4Dvg'><tfoot id='s4Dvg'></tfoot><dl id='s4Dvg'><fieldset id='s4Dvg'></fieldset></dl></div>
              • <tfoot id='s4Dvg'></tfoot>
                  <bdo id='s4Dvg'></bdo><ul id='s4Dvg'></ul>

                  本文介绍了从 python 运行 imagemagick convert(控制台应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 imagemagick 对一些字体进行光栅化,该命令在终端上运行良好:

                  I am trying to rasterize some fonts using imagemagick with this command which works fine from a terminal:

                  convert -size 30x40 xc:white -fill white -fill black -font "fontsHelvetica Regular.ttf" -pointsize 40 -gravity South -draw "text 0,0 'O'" draw_text.gif
                  

                  使用子进程自动运行相同的命令不起作用:

                  Running the same command using subprocess to automate it does not work:

                  try:
                      cmd= ['convert','-size','30x40','xc:white','-fill','white','-fill','black','-font','fontsHelvetica Regular.ttf','-pointsize','40','-gravity','South','-draw',"text 0,0 'O'",'draw_text.gif']
                      #print(cmd)
                      subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)
                  except CalledProcessError as e:
                      print(e)
                      print(e.output)
                  

                  .

                  Command '['convert', '-size', '30x40', 'xc:white-fill', 'white', '-fill', 'black', '-font', 'fonts\Helvetica Regular.ttf', '-pointsize', '40', '-gravity', 'South', '-draw', "text 0,0 'O'", 'draw_text.gif']' returned non-zero exit status 4
                  b'Invalid Parameter - 30x40
                  '
                  

                  推荐答案

                  我想通了:原来windows在PATH<中有自己的convert.exe程序/code>.

                  I figured it out: It turns out that windows has its own convert.exe program in PATH.

                  以下代码打印 b'C:\Windows\System32\convert.exe ':

                  The following code prints b'C:\Windows\System32\convert.exe ':

                  try:
                      print(subprocess.check_output(["where",'convert'],stderr=subprocess.STDOUT,shell=True))
                  except CalledProcessError as e:
                      print(e)
                      print(e.output)
                  

                  在终端中运行相同的代码表明 imagemagick 的 convert 会影响 Windows 的 convert:

                  Running the same code in a terminal shows that imagemagick's convert shadows Windows' convert:

                  C:UsersNavin>where convert                                                    
                  C:Program FilesImageMagick-6.8.3-Q16convert.exe                              
                  C:WindowsSystem32convert.exe                                                 
                  

                  .

                  安装 ImageMagick 后我没有重新启动 python,所以它的 PATH 仍然指向 Windows 版本.

                  I did not restart python after installing ImageMagick so its PATH still pointed to the Windows version.

                  使用完整路径有效:

                  try:
                      cmd= ['C:Program FilesImageMagick-6.8.3-Q16convert','-size','30x40','xc:white','-fill','white','-fill','black','-font','fontsHelvetica Regular.ttf','-pointsize','40','-gravity','South','-draw',"text 0,0 'P'",'draw_text.gif']
                      print(str.join(' ', cmd))
                      print('stdout: {}'.format(subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)))
                  except CalledProcessError as e:
                      print(e)
                      print(e.output)
                  

                  这篇关于从 python 运行 imagemagick convert(控制台应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tfoot id='WUKFe'></tfoot>

                        <bdo id='WUKFe'></bdo><ul id='WUKFe'></ul>
                      • <small id='WUKFe'></small><noframes id='WUKFe'>

                        <i id='WUKFe'><tr id='WUKFe'><dt id='WUKFe'><q id='WUKFe'><span id='WUKFe'><b id='WUKFe'><form id='WUKFe'><ins id='WUKFe'></ins><ul id='WUKFe'></ul><sub id='WUKFe'></sub></form><legend id='WUKFe'></legend><bdo id='WUKFe'><pre id='WUKFe'><center id='WUKFe'></center></pre></bdo></b><th id='WUKFe'></th></span></q></dt></tr></i><div id='WUKFe'><tfoot id='WUKFe'></tfoot><dl id='WUKFe'><fieldset id='WUKFe'></fieldset></dl></div>
                      • <legend id='WUKFe'><style id='WUKFe'><dir id='WUKFe'><q id='WUKFe'></q></dir></style></legend>

                            <tbody id='WUKFe'></tbody>