Inner = Image.open(BytesIO(png)).convert('L') # Draw inner white rounded rect, offset by thickness into memory as PNG # Draw outer black rounded rect into memory as PNG # Get input image width and height, and calculate output width and height I fancied my hand at drawing rounded rectangles with SVG for a change - not least because somebody thinks I always use ImageMagick -) #!/usr/bin/env python3 It's the same concept as used in my other answer with some more code on the correct transparency stuff. Img = cv2.imread('path/to/your/image.png') New_image = new_image * (1 - mask) + temp * mask Mask = np.stack((mask, mask, mask), axis=2) # Create new image (three-channel hardcoded here.) ![]() :return: new image as NumPy array with rounded corners photos, to the method and get the image including a border with rounded corners, and transparency outside the border! import cv2ĭef rect_with_rounded_corners(image, r, t, c): →You cannot use “For Reference Only” content in any manner that entails advertising, marketing or commercialization of any product or service.įor Full Edition of Pikbest License Agreement, please click here to the Pikbest License page.After some discussion with Mark in the comments on my first answer, I decided to make another solution using OpenCV and NumPy, which is able to easily feed some real images, e.g. →You cannot imply that the content is created or claimed to be the copyright of the artwork by you or someone other than the copyright holder of the Pikbest content. →You can only use an Item for lawful purposes. ![]() You can’tĬlaim trademark or service mark rights over an Item within the End Product created using that Item. →You cannot use the content in the Pikbest Content (totally or partially) in any trademark, logo or part of the same. →You cannot use the content in the Pikbest Content in printed or electronic items aimed to be resold. →You cannot resell, redistribute, access, share or transfer Pikbest Content. While privileges are different upon different user types, there are some restrictions which are applicable to all Pikbest users. The Pikbest Authorization differs upon different situations. Pikbest authorizes the User in a non-transferable, non-exclusive manner and on a worldwide basis for the duration of the relevant rights to download, use and modify the Pikbest Content, as expressly permitted by the applicable license and subject to this document.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |