• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tasks.resize_preview函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.developers.tasks.resize_preview函数的典型用法代码示例。如果您正苦于以下问题:Python resize_preview函数的具体用法?Python resize_preview怎么用?Python resize_preview使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了resize_preview函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: generate_preview

def generate_preview(app, n=1):
    im = Image.new("RGB", (320, 480), "#" + hashlib.md5(unicode(app.name).encode("utf8") + chr(n)).hexdigest()[:6])
    p = Preview.objects.create(
        addon=app, filetype="image/png", thumbtype="image/png", caption="screenshot " + str(n), position=n
    )
    f = tempfile.NamedTemporaryFile()
    im.save(f, "png")
    resize_preview(f.name, p)
开发者ID:rctgamer3,项目名称:zamboni,代码行数:8,代码来源:tasks.py


示例2: test_preview_rotated

 def test_preview_rotated(self):
     addon = Webapp.objects.get(pk=337141)
     preview = Preview.objects.create(addon=addon, caption='Test')
     src = get_image_path('preview_landscape.jpg')
     tasks.resize_preview(src, preview)
     preview = preview.reload()
     eq_(preview.image_size, [533, 400])
     eq_(preview.thumbnail_size, [240, 180])
     eq_(preview.is_landscape, True)
     with storage.open(preview.thumbnail_path) as fp:
         im = Image.open(fp)
         eq_(list(im.size), [240, 180])
开发者ID:at13,项目名称:zamboni,代码行数:12,代码来源:test_tasks.py


示例3: test_preview

 def test_preview(self):
     addon = Webapp.objects.get(pk=337141)
     preview = Preview.objects.create(addon=addon)
     src = get_image_path('preview.jpg')
     tasks.resize_preview(src, preview)
     preview = preview.reload()
     eq_(preview.image_size, [400, 533])
     eq_(preview.thumbnail_size, [180, 240])
     eq_(preview.is_landscape, False)
     with storage.open(preview.thumbnail_path) as fp:
         im = Image.open(fp)
         eq_(list(im.size), [180, 240])
开发者ID:hardikj,项目名称:zamboni,代码行数:12,代码来源:test_tasks.py


示例4: test_preview_dont_generate_image

 def test_preview_dont_generate_image(self):
     addon = Webapp.objects.get(pk=337141)
     preview = Preview.objects.create(addon=addon)
     src = self.get_image('preview.jpg')
     tasks.resize_preview(src, preview, generate_image=False)
     preview = preview.reload()
     eq_(preview.image_size, [])
     eq_(preview.thumbnail_size, [100, 133])
     eq_(preview.sizes, {u'thumbnail': [100, 133]})
     with storage.open(preview.thumbnail_path) as fp:
         im = Image.open(fp)
         eq_(list(im.size), [100, 133])
     assert not os.path.exists(preview.image_path), preview.image_path
开发者ID:j-barron,项目名称:zamboni,代码行数:13,代码来源:test_tasks.py


示例5: generate_previews

def generate_previews(app, n=1):
    gen = pydenticon.Generator(8, 12, foreground=foreground, digest=hashlib.sha512)
    for i in range(n):
        img = gen.generate(unicode(app.name) + unichr(i), 320, 480, output_format="png")
        p = Preview.objects.create(addon=app, filetype="image/png", caption="screenshot " + str(i), position=i)
        fn = tempfile.mktemp()
        try:
            f = private_storage.open(fn, "w")
            f.write(img)
            f.close()
            resize_preview(fn, p.pk)
        finally:
            private_storage.delete(fn)
开发者ID:jostw,项目名称:zamboni,代码行数:13,代码来源:fakedata.py


示例6: generate_previews

def generate_previews(app, n=1):
    gen = pydenticon.Generator(8, 12, foreground=foreground,
                               digest=hashlib.sha512)
    for i in range(n):
        img = gen.generate(unicode(app.name) + unichr(i), 320, 480,
                           output_format="png")
        p = Preview.objects.create(addon=app, filetype="image/png",
                                   thumbtype="image/png",
                                   caption="screenshot " + str(i),
                                   position=i)
        f = tempfile.NamedTemporaryFile(suffix='.png')
        f.write(img)
        f.flush()
        resize_preview(f.name, p.pk)
开发者ID:Jobava,项目名称:zamboni,代码行数:14,代码来源:fakedata.py


示例7: test_preview_rotated

 def test_preview_rotated(self):
     addon = Webapp.objects.get(pk=337141)
     preview = Preview.objects.create(addon=addon)
     src = self.get_image('preview_landscape.jpg')
     tasks.resize_preview(src, preview.pk)
     preview = preview.reload()
     eq_(preview.image_size, [533, 400])
     eq_(preview.thumbnail_size, [133, 100])
     eq_(preview.is_landscape, True)
     with public_storage.open(preview.thumbnail_path) as fp:
         im = Image.open(fp)
         eq_(list(im.size), [133, 100])
     with public_storage.open(preview.image_path) as fp:
         im = Image.open(fp)
         eq_(list(im.size), [533, 400])
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:15,代码来源:test_tasks.py


示例8: generate_app_from_spec

def generate_app_from_spec(name, categories, type, status, num_previews=1,
                           num_ratings=1, num_locales=0, preview_files=(),
                           author='[email protected]',
                           premium_type='free', description=None, **spec):
    status = STATUS_CHOICES_API_LOOKUP[status]
    if type == 'hosted':
        app = generate_hosted_app(name, categories, author,
                                  status=status, **spec)
    else:
        app = generate_packaged_app(
            name, type, categories, author,
            status=status, **spec)
    generate_icon(app)
    if not preview_files:
        generate_previews(app, num_previews)
    if preview_files:
        for i, f in enumerate(preview_files):
            p = Preview.objects.create(addon=app, filetype="image/png",
                                       thumbtype="image/png",
                                       caption="screenshot " + str(i),
                                       position=i)
        resize_preview(f, p)
    generate_ratings(app, num_ratings)
    app.name = generate_localized_names(app.name, num_locales)
    if not description:
        description = requests.get('http://baconipsum.com/api/'
                                   '?type=meat-and-filler&paras=2'
                                   '&start-with-lorem=1').json()[0]
    app.description = description
    app.support_email = author
    premium_type = mkt.ADDON_PREMIUM_API_LOOKUP[premium_type]
    app.premium_type = premium_type
    if premium_type != mkt.ADDON_FREE:
        acct = get_or_create_payment_account()
        AddonPaymentAccount.objects.create(addon=app, payment_account=acct,
                                           account_uri=acct.uri,
                                           product_uri=app.app_slug)
        price = get_or_create_price(spec.get('price', '0.99'))
        AddonPremium.objects.create(addon=app, price=price)
        app.solitude_public_id = 'fake'
    # Status has to be updated at the end because STATUS_DELETED apps can't
    # be saved.
    app.status = status
    app.save()
    addon_review_aggregates(app.pk)
    u = create_user(author)
    AddonUser.objects.create(user=u, addon=app)
    return app
开发者ID:clouserw,项目名称:zamboni,代码行数:48,代码来源:fakedata.py


示例9: generate_app_from_spec

def generate_app_from_spec(name, categories, type, status, num_previews=1,
                           num_ratings=1, locale_names=('en-US', 'es-ES'),
                           preview_files=(),
                           video_files=(),
                           developer_name='Fake App Developer',
                           developer_email='[email protected]',
                           privacy_policy='Fake privacy policy',
                           premium_type='free', description=None,
                           default_locale='en-US', rereview=False,
                           special_regions={}, inapp_id=None,
                           inapp_secret=None, popularity=0, **spec):
    status = STATUS_CHOICES_API_LOOKUP[status]
    names = generate_localized_names(name, locale_names)
    if type == 'hosted':
        app = generate_hosted_app(
            names[default_locale], categories, developer_name, status=status,
            default_locale=default_locale, **spec)
    else:
        app = generate_packaged_app(
            names, type, categories, developer_name,
            default_locale=default_locale, status=status, **spec)
    generate_icon(app)
    if not preview_files:
        generate_previews(app, num_previews)
    if video_files:
        for i, f in enumerate(video_files):
            t = tempfile.mktemp()
            copy_stored_file(f, t, src_storage=local_storage,
                             dst_storage=private_storage)
            p = Preview.objects.create(addon=app, filetype="video/webm",
                                       caption="video " + str(i),
                                       position=i)
            resize_video(t, p.pk)
    if preview_files:
        for i, f in enumerate(preview_files):
            p = Preview.objects.create(addon=app, filetype="image/png",
                                       caption="screenshot " + str(i),
                                       position=i + len(video_files))
            t = tempfile.mktemp()
            copy_stored_file(f, t, src_storage=local_storage,
                             dst_storage=private_storage)
            resize_preview(t, p.pk)
    generate_ratings(app, num_ratings)
    app.name = names
    if not description:
        description = GENERIC_DESCRIPTION
    app.description = description
    app.privacy_policy = privacy_policy
    app.support_email = developer_email
    premium_type = mkt.ADDON_PREMIUM_API_LOOKUP[premium_type]
    app.premium_type = premium_type
    app.default_locale = default_locale
    if popularity:
        app.popularity.create(value=popularity)
    if premium_type != mkt.ADDON_FREE and status != mkt.STATUS_NULL:
        acct = get_or_create_payment_account(developer_email, developer_name)
        product_uri = Reference().product_create(acct, app)
        AddonPaymentAccount.objects.create(addon=app, payment_account=acct,
                                           account_uri=acct.uri,
                                           product_uri=product_uri)
        if premium_type in (mkt.ADDON_PREMIUM, mkt.ADDON_PREMIUM_INAPP):
            price = get_or_create_price(spec.get('price', '0.99'))
            AddonPremium.objects.create(addon=app, price=price)
        if premium_type in (mkt.ADDON_FREE_INAPP, mkt.ADDON_PREMIUM_INAPP):
            UserInappKey.create(acct.user, secret=inapp_secret,
                                public_id=inapp_id,
                                access_type=ACCESS_PURCHASE)

    for optField in ('support_url', 'homepage', 'is_offline'):
        if optField in spec:
            setattr(app, optField, spec[optField])
    # Status has to be updated at the end because STATUS_DELETED apps can't
    # be saved.
    app.status = status
    app.save()
    for (region, region_status) in special_regions.iteritems():
        app.geodata.update(**{'region_%s_nominated' % (region,):
                              datetime.datetime.now(),
                              'region_%s_status' % (region,):
                              STATUS_CHOICES_API_LOOKUP[region_status]})
    addon_review_aggregates(app.pk)
    if rereview:
        RereviewQueue.objects.get_or_create(addon=app)
    try:
        u = UserProfile.objects.get(email=developer_email)
    except UserProfile.DoesNotExist:
        u = create_user(developer_email)
        u.display_name = developer_name
        u.save()
    AddonUser.objects.create(user=u, addon=app)
    return app
开发者ID:carriercomm,项目名称:zamboni,代码行数:91,代码来源:fakedata.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tasks.save_icon函数代码示例发布时间:2022-05-27
下一篇:
Python tasks.region_exclude函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap