本文整理汇总了Python中pgmagick.Image.sharpen方法的典型用法代码示例。如果您正苦于以下问题:Python Image.sharpen方法的具体用法?Python Image.sharpen怎么用?Python Image.sharpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgmagick.Image
的用法示例。
在下文中一共展示了Image.sharpen方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: crop
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import sharpen [as 别名]
def crop(request, block):
id = int(request.GET.get('id', -1))
data = json.loads(request.GET.get('data', []))
from core.models import File
file = File.objects.get(id=id)
file_crop_data = file.data.get('scale', {})
from pgmagick import Image, Geometry
file_path = '%s/%s' % (MEDIA_ROOT, file.path)
full_file_path = '%s/%s' % (file_path, file.file_name)
for crop_data in data:
#
# do not crop same image twice
#
if crop_data['name'] in file_crop_data:
local_crop_data = file_crop_data[crop_data['name']]
if 'scaled_width' in local_crop_data and 'scaled_height' in local_crop_data and 'crop_x' in local_crop_data and 'crop_y' in local_crop_data:
if local_crop_data['scaled_width'] == int(crop_data['scaled_width']) and local_crop_data['scaled_height'] == int(crop_data['scaled_height']) and local_crop_data['crop_x'] == int(crop_data['crop_x']) and local_crop_data['crop_y'] == int(
crop_data['crop_y']):
continue
image = Image(str(full_file_path))
g = Geometry(int(crop_data['scaled_width']), int(crop_data['scaled_height']), 0, 0)
image.scale(g)
gc = Geometry(int(crop_data['width']), int(crop_data['height']), int(crop_data['crop_x']), int(crop_data['crop_y']))
image.crop(gc)
image.quality(100)
image.sharpen(1.0)
full_scaled_image_path = '%s/%s_%s' % (file_path, crop_data['prefix'], file.file_name)
image.write(str(full_scaled_image_path))
scale_data = dict(
width=int(crop_data['width']),
height=int(crop_data['height']),
scaled_width=int(crop_data['scaled_width']),
scaled_height=int(crop_data['scaled_height']),
crop_x=int(crop_data['crop_x']),
crop_y=int(crop_data['crop_y']),
center_x=crop_data['center_x'],
center_y=crop_data['center_y'],
quality=100,
sharpen=1.0,
prefix=crop_data['prefix'],
name=crop_data['name'],
cropped=True
)
file.data['scale'][crop_data['name']] = scale_data
file.save()
return dict(status='success', message='Image %s was successfully cropped.' % file.title, id=id)
示例2: test
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import sharpen [as 别名]
def test():
from pgmagick import Image, FilterTypes
im = Image( './chambres-deluxes-I/chambre-101-s-474.tif' )
im.quality( 100 )
im.filterType( FilterTypes.SincFilter )
im.scale( '100x100' )
im.sharpen( 1.0 )
im.write( 'output.jpg' )
示例3: addScreenshot
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import sharpen [as 别名]
def addScreenshot(f, arg, user_id, item):
if item == 'map':
Object = Maps.objects.filter(id=arg)
if not Object:
return False
if not (Object[0].user_id == user_id.id or user_id.is_superuser):
return False
else:
return False
tempname = '/tmp/screenshot.temp'
with open(tempname, 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
command = 'file -b --mime-type %s' % tempname
proc = Popen(command.split(), stdout=PIPE).communicate()
mimetype = proc[0].strip()
if mimetype not in ['image/jpeg','image/png','image/gif']:
return False
userObject = User.objects.get(pk=Object[0].user_id)
transac = Screenshots(
user = userObject,
ex_id = int(arg),
ex_name = item+"s",
posted = timezone.now(),
map_preview = False,
)
transac.save()
path = os.getcwd() + os.sep + __name__.split('.')[0] + '/data/screenshots/' + str(transac.id) + '/'
if not os.path.exists(path):
os.makedirs(path)
shutil.move(tempname, path + arg + "." + mimetype.split('/')[1])
command = 'identify -format "%w,%h" {0}'.format(path + arg + "." + mimetype.split('/')[1])
proc = Popen(command.split(), stdout=PIPE).communicate()
details = proc[0].strip().strip('"').split(',')
im = Image(Blob(open(path + arg + "." + mimetype.split('/')[1]).read()), Geometry(int(details[0]),int(details[1])))
scaleH = int(details[0]) / 100.0
scaleH = 250 / scaleH
scaleH = int(details[1]) / 100.0 * scaleH
im.quality(100)
im.filterType(FilterTypes.SincFilter)
im.scale('250x%s' % scaleH)
im.sharpen(1.0)
im.write(str(path + arg + "-mini." + mimetype.split('/')[1]))
示例4: watercolor
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import sharpen [as 别名]
def watercolor(self,imgStr):
img=Image(imgStr)
img.blur(2,2)
img.oilPaint(5)
img.enhance()
img.sharpen()
pink=Color(250,218,221,75)
toplayer=Image(img.size(),pink)
toplayer.matte(True)
img.matte(True)
img.composite(toplayer,0,0,CompositeOperator.CopyOpacityCompositeOp)
img.blur(2,2)
#img.write('watercolor-output.png')
return img
示例5: Image
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import sharpen [as 别名]
import sys
from pgmagick import Image, FilterTypes as ft
# same
# convert SRC.jpg -filter Sinc -resize 500x500 -sharpen 1 -quality 100 DST.jpg
# gm convert SRC.jpg -filter Sinc -resize 500x500 -sharpen 1 -quality 100 DST.jpg
im = Image('./X.jpg')
im.quality(100)
im.sharpen(1.0)
im.write('./Y.jpg')
im = Image('./X.jpg')
im.quality(100)
im.filterType(ft.SincFilter)
im.scale('1000x1000')
im.sharpen(1.0)
im.write('./Y.jpg')
im = Image('./X.jpg')
im.quality(100)
im.filterType(ft.SincFilter)
im.scale('100x100')
im.sharpen(1.0)
im.write('./Y.jpg')
im = Image('./X.jpg')
im.quality(100)
im.filterType(ft.SincFilter)
im.scale('500x500')
im.sharpen(1.0)