try:
original = PythonMagick.Blob(data)
image = PythonMagick.Image(original)
except Exception as e:
raise errors.UnknownFileFormat()
medium = PythonMagick.Blob()
small = PythonMagick.Blob()
large = PythonMagick.Blob()
largesize = "128X128"
mediumsize = "64X64"
smallsize = "48X48"
image.scale(largesize)
image.write(large)
image.scale(mediumsize)
image.write(medium)
image.scale(smallsize)
image.write(small)
Now, what I need is to create a base image of each of the sizes and overlay these images on top of it. So that when I show display in an img tag with fixed width and height, the browser does not stretch them. The lack of documentation is aggravating me.
You can probably achieve what you are trying to do in CSS by background-size:cover
or background-size:contain
and background-position:...;
. May be more complicated if trying to do other things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With