Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Release 0.3.0
Browse files Browse the repository at this point in the history
Added function to crop images.
  • Loading branch information
riderius committed Oct 14, 2020
1 parent 58812ab commit f472c8b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 34 deletions.
Binary file modified Image-Viewer.exe
Binary file not shown.
97 changes: 64 additions & 33 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import sys
import webbrowser
from tkinter import Tk, Menu, Canvas, messagebox
from tkinter import Tk, Menu, Canvas, messagebox, Label, Entry, Button
from PIL import Image, ImageTk

LICENSE_TEXT = """

def show_license():
""" This function shows the license. """

messagebox.showinfo('License', """
MIT License
Copyright (c) 2020
Expand All @@ -28,53 +32,80 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

""")

def show_license():
""" This function shows the license. """

messagebox.showinfo('License', LICENSE_TEXT)

def opening_github():
""" This function opens the github. """

webbrowser.open('https://github.com/RIDERIUS/Image-Viewer')


def show_version():
""" This function shows the version. """

messagebox.showinfo('Version', 'Version 0.2.0')
messagebox.showinfo('Version', 'Version 0.3.0')


def crop_image():
""" This function is needed to crop images. """

def cropping():
"""This function will crop images."""
root.geometry(
f"{x_entry_cropping_window.get()}x{y_entry_cropping_window.get()}")
root.mainloop()

cropping_window = Tk()
cropping_window.geometry('404x65')
cropping_window.title('Crop Image')
cropping_window.resizable(False, False)

x_label_cropping_window = Label(cropping_window, text='Width Image')
x_label_cropping_window.grid(column=0, row=0)
y_label_cropping_window = Label(cropping_window, text='Height Image')
y_label_cropping_window.grid(column=2, row=0)

x_entry_cropping_window = Entry(cropping_window,)
x_entry_cropping_window.grid(column=1, row=0)
y_entry_cropping_window = Entry(cropping_window)
y_entry_cropping_window.grid(column=3, row=0)

button_cropping_window = Button(
cropping_window, text='Submit', command=cropping)
button_cropping_window.grid(column=2, row=1)

cropping_window.mainloop()


FILE_PATH = str(sys.argv[1])

def main():
""" Main function in the image viewer. """
image_pil = Image.open(FILE_PATH)
(width, height) = image_pil.size

file_path = str(sys.argv[1])
root = Tk()
root.title("Image-Viewer")
root.geometry(f'{width}x{height}')
root.resizable(False, False)

image_pil = Image.open(file_path)
(width, height) = image_pil.size
image_pil = image_pil.resize(
(width, int(image_pil.size[1] * (width / image_pil.size[0]))), Image.ANTIALIAS)
menu = Menu(root)
root.config(menu=menu)

root = Tk()
root.title("Image-Viewer")
root.geometry(f'{width}x{height}')
root.resizable(False, False)
about_menu = Menu(menu)
edit_image_menu = Menu(menu)

menu = Menu(root)
new_item = Menu(menu)
new_item.add_command(label='License', command=show_license)
new_item.add_command(label='Github', command=opening_github)
new_item.add_command(label='Version', command=show_version)
menu.add_cascade(label='About', menu=new_item)
root.config(menu=menu)
about_menu.add_command(label='License', command=show_license)
about_menu.add_command(label='Github', command=opening_github)
about_menu.add_command(label='Version', command=show_version)
edit_image_menu.add_command(label='Crop Image', command=crop_image)

image = ImageTk.PhotoImage(image_pil)
menu.add_cascade(label='About', menu=about_menu)
menu.add_cascade(label='Edit Image', menu=edit_image_menu)

canv = Canvas(root, width=width, height=height)
canv.create_image(width / 2, height / 2, image=image)
canv.pack()
image = ImageTk.PhotoImage(image_pil)

root.mainloop()
canv = Canvas(root, width=width, height=height)
canv.create_image(width / 2, height / 2, image=image)
canv.pack()

main()
root.mainloop()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pillow==7.2.0
pillow==7.2.0

0 comments on commit f472c8b

Please sign in to comment.