How to remove white borders from images?

378 views Asked by At

How do I remove the white borders on my custom images?

Note: To clarify this is not just a button issue as the circle is a background image with the same issue.

These were exported with transparent backgrounds so I don't understand the white borders.

from tkinter import *
import tkinter as tk
import random

window = tk.Tk()

window.option_add('font', 'Impact 19')

window.title("Randomizer")

window.geometry("600x900")

back =Canvas(window, bg="#172E38", height=2000, width=1000)


# ----RANDOM SELECT GEN--------
def random_gen():
    Champ = ['Aatrox',
             'Zoe']
    Lane = ['top', 'bottom', 'middle', 'support', 'jungle']
    Build = ['AD', 'Tank', 'AP', 'Crit', 'Attack speed', 'Assassin']

    x = random.choice(Build)
    y = random.choice(Champ)
    z = random.choice(Lane)

    return (x, y, z)


# TEST FUNCTION-------------
def random_display():
    result = random_gen()
    label.config(text=result, bg="#172E38", fg="#C49E4E", font=1000)


# Background----------------

C = Canvas(window, borderwidth=0)
filename = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/button44-01.png")
background_label = Label(window, image=filename)
background_label.place(x=25, y=174)

# -----BUTTON---------------


label = Label(window, text="", font=1000, height=1, width=41, bg="#172E38")
label.place(x=120, y=425)

button = tk.Button(text="Goodluck!", command=random_display, font=500, borderwidth=-5, relief=FLAT)
img = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/button1t-01.png")
button.config(image=img)
button.place(x=188, y=613)

button = tk.Button(command=window.quit, borderwidth=0)
exit = PhotoImage(file="C:/Users/wrped/OneDrive/Desktop/exit-01.png")
button.config(image=exit)
button.place(x=228, y=690)

C.place(x=200, y=200)

back.pack()


window.mainloop()

P.S. I'm new here I don't know what to do this is simple to explain I can describe this in a ton of text and it won't let me post because there's too much code - so if someone can give me tips for future posts that would be great!

1

There are 1 answers

1
Yashovardhan Singh On

You can easily remove white borders from your image using Adobe Photoshop. I do not want to reinvent the wheel so you can go here, or you can also use this border editing software.