adhocracy_core.resources.image module¶
image resource type.
-
allow_view_eveyone(context: <InterfaceClass adhocracy_core.interfaces.IResource>, registry: pyramid.registry.Registry, options: dict)[source]¶ Add view permission for everyone for context.
-
interface
IImageDownload[source]¶ Extends:
adhocracy_core.resources.asset.IAssetDownloadDownloadable binary file for Images.
-
class
ImageDownload(stream=None, mimetype=None, title='')[source]¶ Bases:
substanced.file.File,adhocracy_core.resources.asset.AssetDownloadAllow downloading the first image file in the term:lineage.
The constructor of a File object.
streamshould be a filelike object (an object with areadmethod that takes a size argument) orNone. If stream isNone, the blob attached to this file object is created empty.titlemust be a string or Unicode object.mimetypemay be any of the following:None, meaning set this file object’s mimetype toapplication/octet-stream(the default).A mimetype string (e.g.
image/gif)The constant
substanced.file.USE_MAGIC, which will derive the mimetype from the stream content (ifstreamis also supplied) using thepython-magiclibrary.Warning
On non-Linux systems, successful use of
substanced.file.USE_MAGICrequires the installation of additional dependencies. See optional_dependencies.
-
dimensions= None¶ adhocracy_core.interfaces.Dimensionto resize the image
-
crop(image: <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/adhocracy3/envs/stable/lib/python3.5/site-packages/PIL/Image.py'>, dimensions: adhocracy_core.interfaces.Dimensions) → <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/adhocracy3/envs/stable/lib/python3.5/site-packages/PIL/Image.py'>[source]¶ Return a cropped version of image.
The returned version will have the same aspect ratio as the target dimensions, but not necessarily the same size, so a further resizing step may be needed. If the original image is wider, it is cropped in X direction so that only the middle part remains. If it’s higher, it’s cropped in Y direction.
If original and target aspect ratio are identical, the image is returned unchanged.
-
interface
IImage[source]¶ Extends:
adhocracy_core.resources.asset.IAssetAn image asset.