It's using 'requires' because that will take the image and do something
with it as a check, before validating the data and writing it to the
database. In this case, it resizes the image as the "check".
You might be able to find a validator that works with sqlform and replace
it's check with the
That won't do anything. You want this:
db.table_name.picture.requires = RESIZE(200, 200)
Form.requires probably does absolutely nothing.
Your table name is 'test' and your field with the image is called 'pic' so
to adapt the imageutils.py example to your site would be this:
db.test.pic.requires
Is there a way to make imageutils.py work with SQLFORM.FACTORY? It works
perfectly with database tables but if I upload a picture through
SQLFORM.factory like this:
form = SQLFORM.factory(Field('pic', 'upload', uploadfolder=os.path.join(
request.folder, 'uploads/')), Field('description', 'text')
there's also a /contrib/imageutils.py ready to use.
Il giorno giovedì 9 maggio 2013 07:22:06 UTC+2, weheh ha scritto:
>
> There are numerous ways to resize uploaded images. Some are done via the
> web server. Others are done within the app. For a couple of my apps I use
> the python PIL package
There are numerous ways to resize uploaded images. Some are done via the
web server. Others are done within the app. For a couple of my apps I use
the python PIL package to resize uploaded images to thumbnails and the
like. Here's a code fragment that shows how to do it:
def resize_image(table,
5 matches
Mail list logo