我见过无法将 PDF 转换为图像,因为“未定义图像”错误- 但这似乎与 PDF 特别相关。
在这里,我尝试做其他事情 - 只是使用在https://imagemagick.org/Usage/draw/#circles;我在bash
Windows 10 上的 MSYS2 shell 中:
$ magick -version
Version: ImageMagick 7.0.10-11 Q16 x86_64 2020-09-04 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fftw flif fontconfig freetype gslib gvc heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf xml zlib
$ magick convert -size 300x300 -stroke SeaGreen -fill PaleGreen -strokewidth 2 -draw 'translate 50,30 circle 0,0 25,0' circle01.png
convert: no images defined `circle01.png' @ error/convert.c/ConvertImageCommand/3282.
$ magick convert -size 300x300 -stroke SeaGreen -fill PaleGreen -strokewidth 2 -draw 'translate 50,30 circle 0,0 25,0' circle01.png -debug all
2020-11-18T09:27:57+00:00 0:00.003 0.000u 7.0.10 Configure convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/utility.c/ExpandFilenames/971/Configure
Command line: convert {-size} {300x300} {-stroke} {SeaGreen} {-fill} {PaleGreen} {-strokewidth} {2} {-draw} {translate 50,30 circle 0,0 25,0} {circle01.png} {-debug} {all}
2020-11-18T09:27:57+00:00 0:00.003 0.000u 7.0.10 Policy convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/policy.c/IsRightsAuthorized/611/Policy
Domain: Module; rights=Read; pattern="PNG" ...
2020-11-18T09:27:57+00:00 0:00.004 0.000u 7.0.10 Module convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/module.c/OpenModule/1278/Module
Searching for module "PNG" using filename "png.la"
2020-11-18T09:27:57+00:00 0:00.004 0.000u 7.0.10 Module convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/module.c/GetMagickModulePath/547/Module
Searching for coder module file "png.la" ...
2020-11-18T09:27:57+00:00 0:00.025 0.000u 7.0.10 Module convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/module.c/OpenModule/1287/Module
Opening module at path "C:/msys64/mingw64/lib/ImageMagick-7.0.10/modules-Q16HDRI/coders\png.la"
2020-11-18T09:27:58+00:00 0:00.122 0.047u 7.0.10 Module convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/module.c/OpenModule/1314/Module
Method "RegisterPNGImage" in module "PNG" at address 00007FFD8EF21B80
2020-11-18T09:27:58+00:00 0:00.122 0.047u 7.0.10 Module convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/module.c/OpenModule/1328/Module
Method "UnregisterPNGImage" in module "PNG" at address 00007FFD8EF22070
2020-11-18T09:27:58+00:00 0:00.140 0.047u 7.0.10 Policy convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/policy.c/IsRightsAuthorized/611/Policy
Domain: Path; rights=Read; pattern="circle01.png" ...
2020-11-18T09:27:58+00:00 0:00.140 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/share/ImageMagick-7/locale.xml"
2020-11-18T09:27:58+00:00 0:00.140 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/lib/ImageMagick-7.0.10/config-Q16HDRIlocale.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/etc/ImageMagick-7/locale.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/share/doc/ImageMagick-7/locale.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:\Users\user\AppData\Local\ImageMagick\locale.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:\msys64\home\user\.config\ImageMagick\locale.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Configure convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/LoadLocaleCache/1206/Configure
Loading locale configure file "C:/msys64/mingw64/share/ImageMagick-7/locale.xml" ...
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/share/ImageMagick-7/english.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/lib/ImageMagick-7.0.10/config-Q16HDRIenglish.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/etc/ImageMagick-7/english.xml"
2020-11-18T09:27:58+00:00 0:00.141 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:/msys64/mingw64/share/doc/ImageMagick-7/english.xml"
2020-11-18T09:27:58+00:00 0:00.142 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:\Users\user\AppData\Local\ImageMagick\english.xml"
2020-11-18T09:27:58+00:00 0:00.142 0.047u 7.0.10 Locale convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/GetLocaleOptions/854/Locale
Searching for locale file: "C:\msys64\home\user\.config\ImageMagick\english.xml"
2020-11-18T09:27:58+00:00 0:00.142 0.047u 7.0.10 Configure convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/locale.c/LoadLocaleCache/1206/Configure
Loading locale configure file "C:/msys64/mingw64/share/ImageMagick-7/english.xml" ...
2020-11-18T09:27:58+00:00 0:00.145 0.047u 7.0.10 Exception convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/blob.c/OpenBlob/3496/Exception
unable to open image 'circle01.png': No such file or directory
2020-11-18T09:27:58+00:00 0:00.145 0.047u 7.0.10 Cache convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/cache.c/DestroyPixelCache/1042/Cache
destroy
2020-11-18T09:27:58+00:00 0:00.146 0.047u 7.0.10 Policy convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/policy.c/IsRightsAuthorized/611/Policy
Domain: Path; rights=Read; pattern="circle01.png" ...
2020-11-18T09:27:58+00:00 0:00.146 0.047u 7.0.10 Exception convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/blob.c/OpenBlob/3496/Exception
unable to open image 'circle01.png': No such file or directory
2020-11-18T09:27:58+00:00 0:00.146 0.047u 7.0.10 Cache convert[4620]: ../ImageMagick-7.0.10-11/MagickCore/cache.c/DestroyPixelCache/1042/Cache
destroy
2020-11-18T09:27:58+00:00 0:00.146 0.047u 7.0.10 Exception convert[4620]: ../ImageMagick-7.0.10-11/MagickWand/convert.c/ConvertImageCommand/3279/Exception
`all'
convert: unable to open image 'circle01.png': No such file or directory @ error/blob.c/OpenBlob/3496.
convert: `all' @ error/convert.c/ConvertImageCommand/3279.
奇怪的是,如果我通过创建一个空文件touch circle01.png
,Imagemagick 会尝试打开它并失败 - 即使我希望 Imagemagick产生这个文件?
如何让它工作?
答案1
呃,似乎我忘了xc:
在命令中包含;所以正确的命令是:
magick convert -size 300x300 xc: -stroke SeaGreen -fill PaleGreen -strokewidth 2 -draw 'translate 50,30 circle 0,0 25,0' circle01.png
...这个可以正常生成文件。