ImageMagick 实现的手撕纸张效果

sh/bash/dash/ksh/zsh等Shell脚本
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

ImageMagick 实现的手撕纸张效果

#1

帖子 lilydjwg » 2011-09-22 18:47

[bash]
#!/bin/bash

if [ $# -ne 2 ]; then
echo "Usage: $0 ORIGINAL_IMAGE NEW_IMAGE" >&2
exit 1
fi

src=$1
dst=$2

convert "$src" \( +clone -threshold -1 -virtual-pixel black -spread 10 -blur 0x3 -threshold 50% -spread 1 -blur 0x.7 \) +matte -compose Copy_Opacity -composite "$dst"
convert "$dst" \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -mosaic +repage "$dst"
[/bash]
盗用 shutter 插件的, :em05
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: ImageMagick 实现的手撕纸张效果

#2

帖子 yjcong » 2011-09-22 19:21

3.png
3.png (24.54 KiB) 查看 1225 次
up
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: ImageMagick 实现的手撕纸张效果

#3

帖子 tenzu » 2011-09-22 19:31

神没来? :em04
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: ImageMagick 实现的手撕纸张效果

#4

帖子 yjcong » 2011-09-22 20:03

tenzu 写了:神没来? :em04
66.jpg
66.jpg (12.03 KiB) 查看 1208 次
NN的, 估计要该参数. 有时间再弄吧
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: ImageMagick 实现的手撕纸张效果

#5

帖子 lilydjwg » 2011-09-22 20:12

yjcong 写了:
tenzu 写了:神没来? :em04
66.jpg
NN的, 估计要该参数. 有时间再弄吧
谁让你用 jpg 了,不知道 jpg 不支持透明啊。。。 :em04
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: ImageMagick 实现的手撕纸张效果

#6

帖子 lilydjwg » 2011-09-22 20:17

yjcong 写了:图片up
来张大图好了:
firefox2.png
firefox2.png (178.67 KiB) 查看 1196 次
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: ImageMagick 实现的手撕纸张效果

#7

帖子 eexpress » 2011-09-22 21:12

继续撕。
● 鸣学
头像
nmsfan
帖子: 18958
注册时间: 2009-10-16 22:46
来自: finland

Re: ImageMagick 实现的手撕纸张效果

#8

帖子 nmsfan » 2011-09-22 21:14

原来jpg不行啊
>>>>推Ubuntu 桌面培训~~<<<<
>>>>想加入/了解gimp汉化吗,点我吧~<<<<
——————————————————————
不推荐wubi,也不推荐你给别人推荐wubi…………
随心而为的感觉真好……
强推mayhem!!
强推ensiferum
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: ImageMagick 实现的手撕纸张效果

#9

帖子 naturalaw » 2011-09-22 21:21

eexpress 写了:继续撕。
:em70
透明区.似乎有个什么alpha通道.
要24+8=32才支持的.?
求解
  • The eternal law
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: ImageMagick 实现的手撕纸张效果

#10

帖子 naturalaw » 2011-09-22 21:25

改造一下.弄成截图撕纸.
  • The eternal law
头像
monk
帖子: 19507
注册时间: 2010-01-28 10:45

Re: ImageMagick 实现的手撕纸张效果

#11

帖子 monk » 2011-09-22 21:29

判断是否png,不是的话转换后再撕

*********宁静致远*********
如果我说的有什么不对,请看签名第一行
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: ImageMagick 实现的手撕纸张效果

#12

帖子 naturalaw » 2011-09-22 21:52

抄了ee的一些代码. :em06

[bash]#!/bin/bash
greenB='\x1b[1;32m'; end='\x1b[0m'; redB='\x1b[1;31m'; blueB='\x1b[1;34m'
TIME=$(date '+%Y-%m-%d-%H-%M-%S')
EXT=png
SCRDIR=${HOME}/Desktop/
if [ ! -d "${SCRDIR}" ]; then
mkdir -p "${SCRDIR}"
fi
echo -e "${redB}Select a window or rectangle with the mouse${end}"
scrot -d 3 -s ${SCRDIR}${TIME}.${EXT}
~/bin/si.sh ${SCRDIR}${TIME}.${EXT} ${SCRDIR}${TIME}.${EXT}.1
mv ${SCRDIR}${TIME}.${EXT}.1 ${SCRDIR}${TIME}.${EXT}
echo ${SCRDIR}${TIME}.${EXT}
feh ${SCRDIR}${TIME}.${EXT}
[/bash]
我把lz的代码保存为si.sh了.
~/bin/si.sh
  • The eternal law
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: ImageMagick 实现的手撕纸张效果

#13

帖子 yjcong » 2011-09-22 21:56

有没有斜着撕的, 比如撕成2个三角形?
------------------------------
撕2次效果
ff.png
ff.png (183.84 KiB) 查看 1163 次
--------------------
撕3次效果
fff.png
fff.png (184.84 KiB) 查看 1164 次
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: ImageMagick 实现的手撕纸张效果

#14

帖子 lilydjwg » 2011-09-22 22:29

monk 写了:判断是否png,不是的话转换后再撕
这个和源图片没关系。其实可以判断目标文件,如果是 jpg 之类不支持透明的,就撕完再把透明部分用白色填充。
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: ImageMagick 实现的手撕纸张效果

#15

帖子 yjcong » 2011-09-23 10:17

从你的链接里, 去了你的网页, 然后读了你的文章. 给你贴一段我的笔记

xte用法(xautomation包)

xte 'mousemove 150 150' 'mousedown 1' 'mouseup 1' 'sleep 1' 'mousemove 571 220' 'mousedown 1' 'mouseup 1' 'key t'
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
回复