0

google.appengine.api.imagesを使用して画像を切り抜こうとしています。

残念ながら、これらのパラメータを使用してサイズ612x612の画像を切り抜こうとすると、Noneが返されます。

(0.0, 0.14052287581699346, 1.0, 0.85947712418300659)

例外や意味のあるエラーメッセージは生成されません。戻り値はNoneです。

何か案が?

編集:

以下は、私が使用しているコード全体です。

path = urllib.unquote(path)
r = urllib.urlopen(path)
image_data = r.read()
img = Image(image_data = image_data)
width, height = float(img.width), float(img.height)
max_height = 440.0
max_width = 940.0

rest_height = 0.0
if height > max_height:
    rest_height = height - max_height

rest_width = 0.0
if width > max_width:
    rest_width = width - max_width

left_x = rest_width/(2 * width)
top_y = rest_height/(2 * height)
right_x = 1.0 - left_x 
bottom_y = 1.0 - top_y

img_cropped = img.crop(left_x,top_y,right_x,bottom_y)
4

1 に答える 1

2

すべての画像操作が指定された後に画像を返すexecute_transformsメソッドを使用する必要があります。切り抜きを指定すると、その操作が実行される操作のキューに追加されるだけで、その時点でイメージインスタンスは返されません。

したがって、「img_cropped = img.execute_transforms()」を実行します。

画像サービスの概要ドキュメントの例をご覧くださいhttps://developers.google.com/appengine/docs/python/images/overview

于 2012-08-27T14:23:26.507 に答える