PIL: Thumbnail and end up with a square image

Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need to end up displaying the image like this: <img src=”/media/image.png” style=”height:36px; width:36px” /> Can I have a letterbox style with either transparent or white around the image? Answer PIL already has a function to do exactly that: from PIL import Image, … Read more

Only PNG supports transparency, is that true?

I found JPG does not support transparency, the alpha value is always 255. I am wondering only png supports transparency? Answer png-32 supports different levels of transparency. Each pixel can have an opacity between 0 and 255, with 0 as completely transparent. png-24 supports setting one color as fully transparent. Everything else will be opaque. … Read more

ImageMagick extend canvas with transparent background

convert input.png -extent 100×100 -gravity center -background white output.png If the input is 50×50 the surrounding background is white. Can I somehow set this to transparent without declaring any color within input as transparent? Answer Use this instead: convert \ input.png \ -background none \ -gravity center \ -extent 100×100 \ output.png Note well: The … Read more

webdesign – jpg or png, which one is the best for web [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago. Improve this question I’ve been a web developer for quite some time, and I am used to transforming all … Read more