DEV Community

Editoro Godwin
Editoro Godwin

Posted on • Updated on

HOW TO BUILD A FAVICON GENERATOR

Who can help me get started please ?

Top comments (2)

Collapse
 
eddyah5 profile image
Editoro Godwin

So I finally found a way but it is not there yet. The code below runs perfectly well but there is a catch.

**from tkinter import *
from tkinter import filedialog as fd
import os
from PIL import Image

root=Tk()
root.geometry("400x400")
root.title("Image_Conversion_App")

def jpg_to_ico():
filename=fd.askopenfilename()
if filename.endswith("JPG"):
Image.open(filename).save("sample1.ico")
else:
Label_2=Label(root,text="Error!", width=20,fg="red", font=("bold",15))
Label_2.place(x=80,y=280)

def png_to_ico():
filename=fd.askopenfilename()
if filename.endswith(".PNG"):
Image.open(filename).save("sample2.ico")
else:
Label_2=Label(root,text="Error!", width=20,fg="red", font=("bold",15))
Label_2.place(x=80,y=280)

Label_1=Label(root,text="Browse A File", width=20, font=("bold",15))
Label_1.place(x=80,y=80)

Label_3=Label(root, text=" \n", width=80, font=("bold",8))
Label_3.place(x=10,y=365)

Button(root,text="JPG_to_ICO", width=20, height=2, bg="brown",fg="white",command=jpg_to_ico).place(x=120,y=120)
Button(root,text="PNG_to_ICO", width=20, height=2, bg="brown",fg="white", command=png_to_ico).place(x=120,y=220)

root.mainloop()**

1) Any picture file extension outside of .JPG or .PNG it gives error as seen in the code. But the aim of this project is to be able to check, accept and convert a wide picture file formats extensions such as:

*"JPG", "JPEG", "jpg", "jpeg", "png", "PNG", "bmp", "BMP", "gif", "GIF", "tiff", "TIFF", "webp", "WEBP" *

But anything outside of the above strings (file extensions should be rejected "Error"

2) Plus this project should be able to let user download the final file .ICO file as a Zip file

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Hi Editoro,

Please move your comment into the main post (where it belongs) and try to be more concise with your questions.

You must search in Google (or your favourite search engine), try to reach the expected target on your App and ask for specific issues or concerns instead asking for "how to code end-to-end" a given product.

Please note that you can use markdown to add your code so it gets formatted:



```python
 // Your code goes here
```


Example:

root=Tk()
root.geometry("400x400")
root.title("Image_Conversion_App")
Enter fullscreen mode Exit fullscreen mode

Best regards