我正在使用Flask_Images
在应用程序主页中裁剪图像,这是我的代码段:
# Images caching
IMAGES_CACHE = '/tmp/myapp.images'
IMAGES_MAX_AGE = 10
IMAGES_PATH = ['static/imgs/products']
images = Images()
from flask_images import Images
images.init_app(app)
<img src="{{resized_img_src(product.image, width=184, height=300, mode='crop', quality=95)}}" />
product_image 路径为 / static / imgs / products
模板内部的路径如下所示:
/imgsizer/static/imgs/products/1-650x350.jpg?h=300&m=crop&q=95&w=400&s=PDe9H78j-PFgpDgKyeFjEPfqr2w