Skip to content

Commit

Permalink
Merge pull request #208 from TeaM-TL/5.1.5
Browse files Browse the repository at this point in the history
5.1.5
  • Loading branch information
TeaM-TL authored Jan 7, 2025
2 parents 6bc0fa2 + e57b7f1 commit 92b299f
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 139 deletions.
49 changes: 31 additions & 18 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload FotoKilof Package to PyPI when a Release is Created
name: Build and upload to PyPI when a Release is Created

on:
release:
Expand All @@ -15,24 +15,37 @@ jobs:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: "Install build"
run: pip install build
- name: Compile *po files for localisation
run: |
apt-get install -y gettext tree
ls
tree
L_PRE=fotokilof/locale
L_LAST=LC_MESSAGES/fotokilof
for L in $L_PRE/??; do
if [ -e $L_PRE/$L/$L_LAST.po ]; then
msgfmt $L_PRE/$L/$L_LAST.po -o fotokilof/$L/$L_LAST.mo
fi
done
- name: Build package
run: python -m build

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: "Install build"
run: pip install build

- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release upload '${{ github.pypi }}' dist/** --repo '${{ github.repository }}'
- name: Build package
run: python -m build

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# - name: Upload artifact signatures to GitHub Release
# env:
# GITHUB_TOKEN: ${{ github.token }}
# run: gh release upload '${{ github.pypi }}' dist/** --repo '${{ github.repository }}'
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2025

5.1.5 fixed right mouse button for crop, small code polishing

## 2024

5.1.4 updated locale and pot file, added missing entry poinyt into toml
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019-2024 Tomasz Łuczak, TeaM-TL
Copyright (c) 2019-2025 Tomasz Łuczak, TeaM-TL
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
GUI for the most used (by me) ImageMagick functionality for processing pictures.
If ImageMagick or Wand are unavailable, Pillow is in use. There some limitation, but works in general.

![Happy new Year](https://raw.githubusercontent.com/TeaM-TL/FotoKilof/master/screenshots/january_happy_new_year.jpg)

## Screenshots

### Linux
Expand Down
18 changes: 10 additions & 8 deletions fotokilof/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pylint: disable=line-too-long

"""
Copyright (c) 2019-2024 Tomasz Łuczak, TeaM-TL
Copyright (c) 2019-2025 Tomasz Łuczak, TeaM-TL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -237,7 +237,7 @@ def preview_new(file_out):
preview_new_clear()
else:
preview_picture = convert_common.preview(
file_out, int(co_preview_selector_new.get()), PILLOW, OS
file_out, int(co_preview_selector_new.get()), PILLOW
)
try:
pi_preview_new.configure(file=preview_picture["filename"])
Expand Down Expand Up @@ -856,7 +856,7 @@ def open_file():
def open_file_common(cwd, filename):
"""common function for: open, first, last, next, prev"""
if filename is not None:
file_in_path.set(common.spacja(os.path.join(cwd, filename), OS))
file_in_path.set(common.spacja(os.path.join(cwd, filename)))
root.title(window_title + file_in_path.get())
image_size = convert_common.get_image_size(file_in_path.get(), PILLOW)
if image_size != (0, 0):
Expand Down Expand Up @@ -983,7 +983,7 @@ def open_screenshot():
except:
if OS == "UNIX":
message = _(
"Sorry, xclip (X11) or wl-clipboard (Wayland) is not installed\n Install xclip or wl-clipboard and try again!"
"Sorry, nothing in clipboard\nOr xclip (X11) or wl-clipboard (Wayland) is not installed\n Install xclip or wl-clipboard and try again!"
)
Messagebox.show_error(message, title=_("Missing package"))
try:
Expand Down Expand Up @@ -1528,7 +1528,6 @@ def preview_orig():
file_in_path.get(),
int(co_preview_selector_orig.get()),
PILLOW,
OS,
crop_rectangle,
)

Expand Down Expand Up @@ -1564,7 +1563,7 @@ def preview_logo():
if os.path.isfile(file_logo_path.get()):
l_logo_filename.configure(text=os.path.basename(file_logo_path.get()))
preview_picture = convert_common.preview(
file_logo_path.get(), PREVIEW_LOGO, PILLOW, OS
file_logo_path.get(), PREVIEW_LOGO, PILLOW
)

try:
Expand All @@ -1591,7 +1590,7 @@ def preview_compose():
if os.path.isfile(img_compose_file.get()):
# l_compose_preview.configure(text=os.path.basename(img_compose_file.get()))
preview_picture = convert_common.preview(
img_compose_file.get(), int(co_compose_preview_selector.get()), PILLOW, OS
img_compose_file.get(), int(co_compose_preview_selector.get()), PILLOW
)

try:
Expand Down Expand Up @@ -3150,7 +3149,10 @@ def text_tool_hide_show():
co_compose_preview_selector.bind("<<ComboboxSelected>>", preview_compose_refresh)
co_text_font.bind("<<ComboboxSelected>>", font_selected)
c_preview_orig_pi.bind("<Button-1>", mouse_crop_nw)
c_preview_orig_pi.bind("<Button-2>", mouse_crop_se)
if OS == "MACOS":
c_preview_orig_pi.bind("<Button-2>", mouse_crop_se)
else:
c_preview_orig_pi.bind("<Button-3>", mouse_crop_se)
c_preview_new_pi.bind("<Button-1>", preview_new_button)
root.bind("<F1>", help_info)
root.bind("<F2>", change_ttk_theme)
Expand Down
19 changes: 7 additions & 12 deletions fotokilof/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
Copyright (c) 2019-2024 Tomasz Łuczak, TeaM-TL
Copyright (c) 2019-2025 Tomasz Łuczak, TeaM-TL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -39,6 +39,7 @@
import fnmatch
import logging
from pathlib import PurePosixPath, PureWindowsPath
import platform
import os
import os.path

Expand All @@ -52,8 +53,7 @@ def resize_subdir(resize_vatiant, pixel_x, pixel_y, percent):
command = str(pixel_x) + "x" + str(pixel_y)
sub_dir = str(pixel_x) + "x" + str(pixel_y)
case 2:
if percent > 100:
percent = 100
percent = min(percent, 100)
if percent == 0:
percent = 1
command = str(percent) + "%"
Expand Down Expand Up @@ -120,10 +120,10 @@ def mouse_crop_calculation(x_orig, y_orig, size):
return dict_return


def spacja(file_path, operating_system):
def spacja(file_path):
"""escaping space and special char in pathname"""
if len(file_path):
if operating_system == "Windows":
if platform.system() == "Windows":
result = PureWindowsPath(os.path.normpath(file_path))
else:
result = PurePosixPath(os.path.normpath(file_path))
Expand Down Expand Up @@ -259,9 +259,7 @@ def file_from_list_of_images(file_list, current_file, request):

def arrow_gravity(position, length, x0, y0):
"""calculate coordinated to draw arrow"""
length = int(length)
x0 = int(x0)
y0 = int(y0)

width = int(length / 3 / 2)
length_1_2 = int(length / 2)
length_1_3 = int(length / 3)
Expand All @@ -270,9 +268,6 @@ def arrow_gravity(position, length, x0, y0):
offset_x = 0
offset_y = 0
c = (x0, y0)
a = (x0, y0)
d = (x0, y0)
e = (x0, y0)
match position:
case "N":
a = (x0, y0 + length)
Expand Down Expand Up @@ -380,7 +375,7 @@ def gravitation(gravity, text_x, text_y, image_width, image_height):
result0 = "0"
result1 = "0"

return (result0, result1), text_x, text_y
return (result0, result1), int(text_x), int(text_y)


def compose_calculate_half(clone, compose, auto_resize, gravity):
Expand Down
29 changes: 22 additions & 7 deletions fotokilof/convert_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint: disable=bare-except

"""
Copyright (c) 2024 Tomasz Łuczak, TeaM-TL
Copyright (c) 2024-2025 Tomasz Łuczak, TeaM-TL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -78,7 +78,6 @@ def fonts_list(set_pillow):

def display_image(file_to_display, set_pillow):
"""display image"""
# file_in = common.spacja(file_to_display)
module_logger.info(" Display file: %s", file_to_display)
start_time = time.time()
result = None
Expand Down Expand Up @@ -134,13 +133,23 @@ def get_image_size(file_in, is_pillow):
return size


def preview(file_logo, size, set_pillow, operating_system, coord=""):
def preview(file_logo, size, set_pillow, coord=""):
"""preview"""
start_time = time.time()

if set_pillow:
result = convert_pillow.preview(file_logo, size, operating_system, coord)
result = convert_pillow.preview(file_logo, size, coord)
else:
result = convert_wand.preview(file_logo, size, operating_system, coord)
result = convert_wand.preview(file_logo, size, coord)
if result is None:
result = {
"filename": None,
"size": "0",
"width": "0",
"height": "0",
"preview_width": "0",
"preview_height": "0",
}
module_logger.info("preview: %s s", str(time.time() - start_time))
return result

Expand Down Expand Up @@ -170,10 +179,16 @@ def save_close_clone(clone, file_out, exif_on, set_pillow):
def rotate(clone, angle, color, angle_own, set_pillow):
"""rotate"""
start_time = time.time()
if angle == 0:
angle = common.empty(angle_own)
if angle == 0:
color = None
else:
color = None
if set_pillow:
result = convert_pillow.rotate(clone, angle, color, angle_own)
result = convert_pillow.rotate(clone, angle, color)
else:
convert_wand.rotate(clone, angle, color, angle_own)
convert_wand.rotate(clone, angle, color)
result = clone
module_logger.info("Rotate: %ss", str(time.time() - start_time))
return result
Expand Down
Loading

0 comments on commit 92b299f

Please sign in to comment.