0

views.py

class imagess(ImageSpec):
    processors = [SmartResize(100,100)]
    format = 'JPEG'
    options = {'quality': 100}

register.generator('main:imagess', imagess)

index.html

{% generateimage 'main:imagess' source=source_file %}

this generates a image of height 100 x 100

how 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 %}
Harsh Jadon
  • 358
  • 2
  • 13

1 Answers1

0

Just add extra attributes and pass them in view function definition, you can use those parameters:

{% generateimage 'myapp:thumbnail' source=source_file height=1080 width=720 %}

Views.py

class imagess(ImageSpec, height, width):
    processors = [SmartResize(height, width)]
    format = 'JPEG'
    options = {'quality': 100}

register.generator('main:imagess', imagess)
Siva Sankar
  • 1,672
  • 1
  • 9
  • 16