小编Der*_*rek的帖子

pyCairo:如何调整图像大小和位置?

基于使用Pycairo创建PDF(调整大小)PNG图像的问题 - 重新缩放Surface问题我试图创建重新调整图像并将图像放置在特定位置的代码,如下面的代码所示(在本例中,例如,图像应显示在"基础矩形"的"上方".但是,我似乎无法让图像显示在正确的位置.

我很高兴知道我必须改变什么,以便正确地缩放定位图像.

import cairo
if not cairo.HAS_PDF_SURFACE:
    raise SystemExit('cairo was not compiled with PDF support')


def draw_image(ctx, image, top, left, height, width):
    """Draw a scaled image on a given context."""
    image_surface = cairo.ImageSurface.create_from_png(image)
    # calculate proportional scaling
    img_height = image_surface.get_height()
    img_width = image_surface.get_width()
    width_ratio = float(width) / float(img_width)
    height_ratio = float(height) / float(img_height)
    scale_xy = min(height_ratio, width_ratio)
    # scale image and add it
    ctx.save()
    ctx.scale(scale_xy, scale_xy)
    ctx.translate(left, top)
    ctx.set_source_surface(image_surface)

    ctx.paint()
    ctx.restore()


def …
Run Code Online (Sandbox Code Playgroud)

python cairo pycairo

9
推荐指数
1
解决办法
6949
查看次数

在Ubuntu 12.04上安装Pandas失败

根据Pandas社区页面(http://pandas.pydata.org/community.html),我首先在这里发帖...

我正在尝试使用pip在运行Ubuntu 12.04.3(64位)的vanilla远程服务器上的虚拟环境中安装Pandas.我已经安装了通常的嫌疑人(python-dev(2.7),numpy,scipy).Pandas没有安装,我不确定要更改或添加什么以确保发生这种情况.

我已经看到其他引用(没有相同的错误)暗示内存可能是一个问题; 远程服务器(Digital Ocean Droplet)只有512MB.

点差错误日志的尾部如下所示:

gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

error: command 'gcc' failed with exit status 4

----------------------------------------

Command /srv/tp/venv/bin/python -c "import setuptools;__file__='/srv/tp/venv/build/pandas/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-0bOHrG-record/install-record.txt --install-headers /srv/tp/venv/include/site/python2.7 failed with error code 1 in /srv/tp/venv/build/pandas

Exception information:
Traceback (most recent call last):
  File "/srv/tp/venv/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 104, in main
    status = self.run(options, args)
  File …
Run Code Online (Sandbox Code Playgroud)

python ubuntu install pandas

3
推荐指数
2
解决办法
2451
查看次数

标签 统计

python ×2

cairo ×1

install ×1

pandas ×1

pycairo ×1

ubuntu ×1