示例#1
0
文件: _util.py 项目: EricDoug/imsto
def watermark_image(filename, distname):
	from image import SimpImage
	im = SimpImage(filename)
	if os.environ.has_key('IMSTO_CONF_DIR'):
		watermark = os.path.join(os.environ['IMSTO_CONF_DIR'], 'watermark.png')
		copyright = os.path.join(os.environ['IMSTO_CONF_DIR'], 'watermark-copy.png')
	else:
		watermark = os.path.join(os.getcwd(), 'config/watermark.png')
		copyright = os.path.join(os.getcwd(), 'config/watermark-copy.png')
	#print ini_file
	im_w = SimpImage(watermark)
	#print im_w.wand
	check_dirs(distname)
	ci = SimpImage(copyright) if os.access(copyright, os.R_OK) else None
	r = None
	if im.watermark(im_w, 0.5, position='golden', copyright=ci):
		print 'watermark ok'
		r = im.save(distname)

	if r is None:
		print 'error watermark'

	del im
	del im_w
	return r
示例#2
0
文件: _util.py 项目: gnemoug/imsto
def thumbnail_wand(filename, size_1, distname, mode='s'):
	from image import SimpImage
	im = SimpImage(filename)
	if mode == 'c':
		ret = im.cropThumbnail(size_1, size_1)
	elif mode == 'w':
		ret = im.thumbnail(size_1, max_width=size_1)
	elif mode == 'h':
		ret = im.thumbnail(size_1, max_height=size_1)
	else:
		ret = im.thumbnail(size_1)

	print "thumbnail {} result: {}".format(size_1, ret)
	if ret:
		ret = im.save(distname)
	del im

	return ret
示例#3
0
文件: _util.py 项目: EricDoug/imsto
def thumbnail_wand(filename, width, height, distname, mode='s'):
	from image import SimpImage
	im = SimpImage(filename)
	if mode == 'c':
		ret = im.cropThumbnail(width, height)
	elif mode == 'w':
		ret = im.thumbnail(width, max_width=width)
	elif mode == 'h':
		ret = im.thumbnail(width, max_height=width)
	else:
		ret = im.thumbnail(width, height)

	print "thumbnail {} {}x{} result: {}".format(mode, width, height, ret)
	if ret:
		ret = im.save(distname)
	del im

	return ret