ImageMagick:识别无法识别XWD图像

我的目标是能够截取所有菜单的屏幕截图,无论工具提示或X窗口抓取下拉菜单,包括Ubuntu中的链轮菜单,例如,像这样,并在另一个绘图工具(如Shutter)中注释它们:

screenshot1

我在Shutter之外做这个的方式(因为它实际上不会抓住那个菜单,即使它正在宣传它),使用xwd来抓取整个根窗口,将其转换为PNG文件,将其加载到Shutter中然后将其裁剪掉。 这样做非常浪费时间,但直到最近才一直在努力。

在Ubuntu上:

 drunkard@norehab:~$ lsb_release -r -i Distributor ID: Ubuntu Release: 17.04 

我使用xwd拍摄完整的截图:

 drunkard@norehab:~$ xwd -root -out /tmp/xwd.tmp.6821 drunkard@norehab:~$ file /tmp/xwd.tmp.6821 /tmp/xwd.tmp.6821: XWD X Window Dump image data, "xwdump", 3840x1215x24 

从XWD转换为PNG格式时遇到错误:

 drunkard@norehab:~$ convert /tmp/xwd.tmp.6821 /home/drunkard/screenshot.2017-10-07.08-13-55.PDT.png convert-im6.q16: no decode delegate for this image format `6821' @ error/constitute.c/ReadImage/504. convert-im6.q16: no images defined `/home/drunkard/screenshot.2017-10-07.08-13-55.PDT.png' @ error/convert.c/ConvertImageCommand/3258. 

我有这个版本的识别:

 drunkard@norehab:~$ file /usr/bin/identify /usr/bin/identify: symbolic link to /etc/alternatives/identify drunkard@norehab:~$ readlink -f /etc/alternatives/identify /usr/bin/identify-im6.q16 drunkard@norehab:~$ apt-file search /usr/bin/identify-im6.q16 imagemagick-6.q16: /usr/bin/identify-im6.q16 imagemagick-6.q16hdri: /usr/bin/identify-im6.q16hdri drunkard@norehab:~$ dpkg --listfiles imagemagick-6.q16 | grep identify /usr/bin/identify-im6.q16 /usr/share/man/man1/identify-im6.q16.1.gz drunkard@norehab:~$ apt-cache --no-all-versions show imagemagick-6.q16 Package: imagemagick-6.q16 Architecture: amd64 Version: 8:6.9.7.4+dfsg-3ubuntu1.2 Multi-Arch: foreign Priority: optional Section: graphics Source: imagemagick Origin: Ubuntu Maintainer: Ubuntu Developers  Original-Maintainer: ImageMagick Packaging Team  Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 644 Provides: imagemagick, imagemagick-6.defaultquantum Depends: libc6 (>= 2.4), libmagickcore-6.q16-3 (>= 8:6.9.6.8), libmagickwand-6.q16-3 (>= 8:6.9.6.8), hicolor-icon-theme Recommends: libmagickcore-6.q16-3-extra, ghostscript, netpbm Suggests: imagemagick-doc, autotrace, cups-bsd | lpr | lprng, curl, enscript, ffmpeg, gimp, gnuplot, grads, graphviz, groff-base, hp2xx, html2ps, libwmf-bin, mplayer, povray, radiance, sane-utils, texlive-base-bin, transfig, ufraw-batch, xdg-utils Breaks: libmagickcore-dev (<< 8:6.9.2.10+dfsg-2~) Replaces: imagemagick (<< 8:6.9.2.10+dfsg-2~) Filename: pool/main/i/imagemagick/imagemagick-6.q16_6.9.7.4+dfsg-3ubuntu1.2_amd64.deb Size: 423848 MD5sum: 6f06b63767fb5e32d967e4395d4e4f98 SHA1: ba0b8af93fed0e9d1efabe56e79387f1bc4944e5 SHA256: 84ffd5f3eb1c8bdc11955c581fc98f1c1bb37eb40609ef6997c8675f1dfd29d0 Homepage: http://www.imagemagick.org/ Description-en: image manipulation programs -- quantum depth Q16 ImageMagick is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. All manipulations can be achieved through shell commands as well as through an X11 graphical interface (display). . For working with the SVG, WMF, OpenEXR, DjVu and Graphviz formats, you need to install the libmagickcore-6.q16-3-extra package. . This version of imagemagick is compiled for a channel depth of 16 bits (Q16). Description-md5: e40daf0bbbffd2b9ac49e04c8c3480fe Task: ubuntu-desktop, ubuntu-usb, print-server, kubuntu-desktop, edubuntu-desktop, edubuntu-usb, xubuntu-core, xubuntu-desktop, mythbuntu-desktop, lubuntu-desktop-share, lubuntu-gtk-desktop, lubuntu-desktop, lubuntu-qt-desktop, ubuntustudio-desktop-core, ubuntustudio-desktop, ubuntu-gnome-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-budgie-desktop Supported: 9m N: There is 1 additional record. Please use the '-a' switch to see it 

但识别不能识别它:

 drunkard@norehab:~$ identify /tmp/xwd.tmp.6821 identify-im6.q16: no decode delegate for this image format `6821' @ error/constitute.c/ReadImage/504. 

这曾经工作过。

解决imagemagick这种可能限制的一种简单方法是略微改变你抓取屏幕截图的技巧。 而不是使用您当前的两步技术:

  1. xwd抓取屏幕截图
  2. imagemagick转换

使用’pipe’使进程成为一个命令

 xwd -root | convert xwd:- test.png 

这在我的系统上运行得很漂亮,可以解决您遇到的问题。 我使用这种技术输入这个答案的截图(裁剪了一些post截图):

在此处输入图像描述

在下面的参考文献中有更多关于利用xwd来实现此目的的想法……

参考文献:

  • HowTo:使用xwd截取屏幕截图

给它一个.xwd文件扩展名:

 drunkard@norehab:~$ cp /tmp/xwd.tmp.6821 /tmp/xwd.tmp.6821.xwd drunkard@norehab:~$ identify /tmp/xwd.tmp.6821.xwd /tmp/xwd.tmp.6821.xwd XWD 3840x1215 3840x1215+0+0 8-bit sRGB 18.67MB 0.000u 0:00.009 

所以这曾经工作过,不需要.xwd文件扩展名。 所以我认为这是一个错误,或者我认为它本来应该工作的用户错误,但是不管文件命名法如何识别图像内容都不是identify的全部点?