6/29/2023 0 Comments Rounded white rectangle pngHere is your image, processed with this code, giving transparent corners: Here is the code: import Image, ImageDrawĭraw.ellipse((0, 0, rad * 2 - 1, rad * 2 - 1), fill=255) Save as a png, thus preserving transparency.Put the alpha channel into your image using putalpha().Chop our circle into four pieces (the rounded corners), and place them in the correct corners of the alpha image.Create an image for the alpha channel the same size as your image.Draws a circle with radius, rad, using draw.ellipse().Below is some pretty nice code that will add transparent corners. the write stuff off the pic,and I still can see the white corner in the pic you processed for meįirst off, make sure you are saving your image in a format that supports transparency. I am so sorry.I need the image shape to be ellipse not rectangle,I.E. How can i get rid of the white background or make it invisible? Then I saved the returned image object,however it has white background in the corner #mask = Image.new('RGB', (image.size - radius, image.size - radius))ĭraw.rectangle((0,0,width,height), aggdraw.Brush('white'))ĭraw.pieslice((0,0,radius*2, radius*2), 90, 180, None, brush)ĭraw.pieslice((width - radius*2, 0, width, radius*2), 0, 90, None, brush)ĭraw.pieslice((0, height - radius * 2, radius*2, height),180, 270, None, brush)ĭraw.pieslice((width - radius * 2, height - radius * 2, width, height), 270, 360, None, brush)ĭraw.rectangle((radius, radius, width - radius, height - radius), brush)ĭraw.rectangle((radius, 0, width - radius, radius), brush)ĭraw.rectangle((0, radius, radius, height-radius), brush)ĭraw.rectangle((radius, height-radius, width-radius, height), brush)ĭraw.rectangle((width-radius, radius, width, height-radius), brush) Optionally, you can fill the removed transparent vertices with any color using the palette in the options or by entering the full color by name, its hex code, RGB code, or RGBA code.I got a square logo and I need to round_corner it, searched for a while and got the follow code "working": def round_corner_jpg(image, radius): If you want to create a perfect circle from a rectangular PNG, then you'll first have to crop it to a square by using our crop png utility, and only then you can make it a perfect circle. To do this, select the circle rounding mode and round each corner by a radius equal to a half of its dimensions, i.e. If you load a PNG image that has equal width and height dimensions (the picture is a square), then you can turn it into a perfect circle. You can switch between the quadratic and circle corner rounding modes in the options. By default, corners are cropped along a quadratic curve line but you can also cut the corners along a circular line. This way, you can remove just one corner from the PNG or multiple corners at once. If you leave any of the radiuses empty, then that vertex won't be rounded. You can control the radius of every vertex in the options. This browser-based program rounds the corners of a PNG picture.
0 Comments
Leave a Reply. |