ImageMagick:identify 无法识别 XWD 图像

ImageMagick:identify 无法识别 XWD 图像

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

截图1

我在 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.

这曾经有效。

答案1

解决此可能限制的一个简单方法imagemagick是稍微改变截屏技术。不要使用当前的 2 步技术:

  1. 使用以下方式截取屏幕截图xwd
  2. 转换imagemagick

使用“管道”来完成这个过程单个命令

xwd -root | convert xwd:- test.png

这在我的系统上运行良好,可以解决您遇到的问题。这是我使用此技术输入此答案的屏幕截图(裁剪了一点帖子屏幕截图):

在此处输入图片描述

xwd下面的参考资料中还有更多可用于此目的的想法……

参考:

答案2

赋予它.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识别图像内容的全部目的无论文件命名如何

相关内容