- 20
- Feb
今天突然想用GScrot截图(因为目前只有它能截取包括Emerald边框完整窗口),可是GScrot自从上次升级后就很久不能用了(我自己写的ebuild)。
估计是哪个依赖错了,于是花了点时间重新写了ebuild,并折腾(截至目前为止,我在2009年提到折腾的次数已经远远超过了前三年!)了其他东西。
打住!
标题可是讲ImageMagick和Pagico,怎么提到GScrot了?
因为我要用GScrot截Pagico的图,然后应用阴影效果。这个阴影效果是用ImageMagick中的convert来搞定的。
对GScrot原来的脚本不是很满意,因为它应用了一个黑色的阴影,而且居然没有处理左边和上面的透明边框,所以很难看。
所以,在让GScrot再一次运行起来后(主要是加了Goo Canvas,又加了个ebuild),我琢磨着怎么才能生成漂亮的阴影效果。
于是看了看ImageMagick的东西,真是太酷了。具体过程不说了,终于让我折腾出来了。
贴源码,处理西北透明边框+10、西北灰阴影+1和东南灰阴影+5,一条命令完成,有点Unix管道的样子。
convert "${FILE}" -gravity northwest -background 'rgba(255,255,255,0)' -splice 1
0x10 \
\( +clone -background gray -shadow 80x3-1-1 \) +swap -background none -mosaic +r
epage \
\( +clone -background gray -shadow 80x3+5+5 \) +swap -background none -mosaic +r
epage "${OUT_FILE}"
我已经把这个加强型阴影处理作为补丁提交给新的Shutter了,希望能接受:
https://bugs.edge.launchpad.net/shutter/+bug/331914。
我现在有点理解为什么Linux Kernel越来越强悍了,因为提交补丁是一种乐趣!
效果图,下图是我截的Pagico图。
之前我有提到我用Tasque来记TODO感觉不爽,所以打算在IMTX加一个TODO功能。不过一直没动,因为复杂度很高。
之所以没用Pagico这款强大的工具,是因为它暂时不支持网络同步。但是这是好解决的,用Dropbox不就得了?
于是我正式开始使用Pagico来处理我的一切事务了。
上图用清晰地图表显示我最近几天的任务,有Ubuntu Tweak,还有Pagico的事务。
Pagico的事务变红了,因为这本来是昨天要做的,过期了。还有其他颜色标识着各种紧急程序和状态,并投在时间线上,所以有东西都一目了然。
Dashboard上的这个图表,是根据People、Data里面的数据动态产生的。比如我答应Pen Jiayong周末包一个Fedora版本。这也显示出来了。
Pagico实在太智能了,简单两句话是说不完的。
总之,有了Pagico,一切都会井井有条!


装了Pagico,但是一直不知道干什么用的,也就没去琢磨!原来是有这么强大的功能!得去看看了....
看起来似乎截图有点竖向拉伸了~
:D
pagico professional需要70$啊。折成人民币得478.5900 ¥
TualatriX 有些那啥了。
屏幕截图 gtk.gdk 自己就能作,
用啥 scrot、imagemagick 之类啊
下边是用 gtk.gdk.Pixbuf.get_from_drawable() 截图
<pre>
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
# Author: 山猫
# License: GNU LGPL
# Last modified:
"""Gtk 截图程序示例
"""
__revision__ = '0.1'
import sys, time
import gtk
def screenshot(filename=''):
w = gtk.gdk.screen_width()
h = gtk.gdk.screen_height()
screenshot = gtk.gdk.Pixbuf.get_from_drawable(
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h),
gtk.gdk.get_default_root_window(),
gtk.gdk.colormap_get_system(),
0, 0, 0, 0, w, h)
screenshot.save(filename or time.strftime('%Y-%m-%d-%s.png'), 'png')
def screenshotthumb(filename='', width=200, height=200):
w = gtk.gdk.screen_width()
h = gtk.gdk.screen_height()
screenshot = gtk.gdk.Pixbuf.get_from_drawable(
gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, w, h),
gtk.gdk.get_default_root_window(),
gtk.gdk.colormap_get_system(),
0, 0, 0, 0, w, h)
width, height = _size(screenshot.get_width(), screenshot.get_height(), width, height)
thumb = screenshot.scale_simple(width, height, gtk.gdk.InterpType(2))
thumb.save(filename or time.strftime('%Y-%m-%d-%s.png'), 'png')
def _scale_size(width, height, twidth, theight):
rw = 1.0 * width/twidth
rh = 1.0 * height/theight
r = max(rh, rw)
return int(width/r), int(height/r)
if __name__=="__main__":
screenshot((sys.argv+[''])[1])
</pre>
devhelp 里边的帮助
gtk.gdk.Pixbuf.get_from_drawable
def get_from_drawable(src, cmap, src_x, src_y, dest_x, dest_y, width, height)
src :
the source gtk.gdk.Drawable.
cmap :
a colormap if src doesn't have one set.
src_x :
the X coordinate within drawable.
src_y :
the Y coordinate within drawable.
dest_x :
the X coordinate in the pixbuf.
dest_y :
the Y coordinate in the pixbuf.
width :
the width in pixels of the region to get.
height :
the height in pixels of the region to get.
Returns :
the pixbuf or None on error
The get_from_drawable() method transfers image data from the gtk.gdk.Drawable specified by src and converts it to an RGB(A) representation inside a gtk.gdk.Pixbuf. In other words, copies image data from a server-side drawable to a client-side RGB(A) buffer. This allows you to efficiently read individual pixels on the client side. If src has no colormap (the gtk.gdk.Drawable.get_colormap() method returns None), then a suitable colormap must be specified as cmap. Typically a gtk.gdk.Window or a pixmap created by passing a gtk.gdk.Window to gtk.gdk.Pixmap() will already have a colormap associated with it. If src has a colormap, the cmap argument will be ignored. If src is a bitmap (1 bit per pixel pixmap), then a colormap is not required; pixels with a value of 1 are assumed to be white, and pixels with a value of 0 are assumed to be black. For taking screenshots, the gtk.gdk.colormap_get_system() function returns the correct colormap to use.
If src is a pixmap, then the requested source rectangle must be completely contained within the pixmap, otherwise the function will return None. For pixmaps only (not for windows) passing -1 for width or height is allowed to mean the full width or height of the pixmap. If src is a window, and the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf. The contents of portions of the pixbuf corresponding to the offscreen region are undefined.
If the window you're obtaining data from is partially obscured by other windows, then the contents of the pixbuf areas corresponding to the obscured regions are undefined. If the target drawable is not mapped (typically because it's iconified/minimized or not on the current workspace), None will be returned. If memory can't be allocated for the return value, None will be returned instead. (In short, there are several ways this method can fail, and if it fails it returns None; so check the return value.)
This method calls the gtk.gdk.Drawable.get_image() method internally and converts the resulting image to a gtk.gdk.Pixbuf, so the documentation for the gtk.gdk.Drawable.get_image() method may also be helpful.
多谢山猫兄,这个例子很好,我看看能不能改造一下变得能截完整的窗口(包括Emerald边框)。
GScrot有点大材小用了。
不错,收下软件及patch