我的目标是能够截取所有菜单的屏幕截图,无论工具提示或 X 窗口抓取下拉菜单,包括 Ubuntu 中的 sprocket 菜单,例如,像这样,并在另一个绘图工具(例如 Shutter)中注释它们:
我在 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 <[email protected]>
Original-Maintainer: ImageMagick Packaging Team <[email protected]>
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
但是Identify无法识别:
drunkard@norehab:~$ identify /tmp/xwd.tmp.6821
identify-im6.q16: no decode delegate for this image format `6821' @ error/constitute.c/ReadImage/504.
这曾经奏效。
解决这个可能的限制的一种简单方法
imagemagick
是稍微改变抓取屏幕截图的技术。而不是使用您当前的两步技术:xwd
imagemagick
使用“管道”使进程成为单个命令:
这在我的系统上运行良好,可以解决您遇到的问题。我使用这种技术输入这个答案的截图(裁剪了一个小帖子截图):
xwd
在下面的参考资料中有更多用于此目的的想法......参考:
给它一个
.xwd
文件扩展名:所以这过去不需要
.xwd
文件扩展名就可以工作。因此,我认为这是一个错误,或者是用户错误,因为我期望它本来应该可以工作,但是无论文件命名如何,identify
识别图像内容的重点不就是吗?