Closed harshjadon9 closed 3 weeks ago
If you want to pass custom with and height to images you can use the {% thumbnail %}
template tag.
If you still want to use your own ImageSpec
then you need to override the __init__
method to accept the arguments that you will give. In your case you probbaly need something like:
class imagess(ImageSpec):
format = 'JPEG'
options = {'quality': 100}
def __init__(self, source, width, height):
processors = [SmartResize(width, height)]
super().__init__(source)
register.generator('main:imagess', imagess)
For inspiration you can use the source code of the ImageSpec
views.py
index.html
{% generateimage 'main:imagess' source=source_file %}
this generates a image of height 100 x 100how can pass/define a custom height and width for the generated image from the HTML file....like
{% generateimage 'main:imagess' source=source_file height=1080 width=720 %}