当前位置: 首页>>代码示例>>Python>>正文


Python Image.sharpen方法代码示例

本文整理汇总了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)
开发者ID:timrc,项目名称:schproj,代码行数:62,代码来源:files.py

示例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' )
开发者ID:NicHub,项目名称:pousadajardimdosanjos-v3-hugosource,代码行数:11,代码来源:tif2jpg.py

示例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]))
开发者ID:temna-net,项目名称:OpenRA-Resources,代码行数:53,代码来源:handlers.py

示例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
开发者ID:adamriggs,项目名称:reddit-api,代码行数:21,代码来源:imgfx.py

示例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)
开发者ID:hhatto,项目名称:pgmagick,代码行数:33,代码来源:pgmagick_prof.py


注:本文中的pgmagick.Image.sharpen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。