Skip to content

Commit

Permalink
5.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaM-TL committed Sep 21, 2024
1 parent 1cfd25d commit b486054
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2024

5.0.2 copy result into clipboard under macos

5.0.1 fix display image in system viewer

5.0.0 use PILLOW if ImageMagick or Wand are unavailable
Expand Down
6 changes: 3 additions & 3 deletions fotokilof/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ def open_screenshot():
magick.magick(" ", "-quiet", out_file, "import")
except:
logging.error("open_screenshot(), error in make screeshot ")
do_it = 1
do_it = 0
if do_it:
open_file_common(today_dir, filename)

Expand Down Expand Up @@ -1893,7 +1893,7 @@ def text_tool_hide_show():
img_border_on = IntVar() # Border
img_border_color = StringVar()
img_normalize_on = IntVar() # Normalize
img_normalize = IntVar() # (1,2,3)
img_normalize = IntVar() # (1,2,3)
normalize_channels = (
"None",
"Red",
Expand Down Expand Up @@ -2925,7 +2925,7 @@ def text_tool_hide_show():
###########################
frame_compose = ttk.LabelFrame(frame_first_col, text=_("Compose"))

### Main
# ## Main
frame_compose_main = ttk.Frame(frame_compose)
b_compose_select = ttk.Button(
frame_compose_main,
Expand Down
46 changes: 35 additions & 11 deletions fotokilof/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,59 @@
"""

from io import BytesIO
import logging
import re
from PIL import Image

import mswindows

if mswindows.windows() == 1:
if mswindows.windows():
import win32clipboard

if mswindows.macos():
import subprocess

module_logger = logging.getLogger(__name__)


def copy_to_clipboard(file_in):
"""
Copy results into clipboard
Copy results into clipboard for Windows
https://stackoverflow.com/questions/34322132/copy-image-to-clipboard
Copy to clipboard works for Windows only
Copy results into clipboard for Macos
https://stackoverflow.com/questions/54008175/copy-an-image-to-macos-clipboard-using-python?rq=4
debug needed!
"""
if mswindows.windows() == 1:
image = Image.open(file_in)

output = BytesIO()
image.convert("RGB").save(output, "BMP")
data = output.getvalue()[14:]
output.close()
image = Image.open(file_in)
# Create an in-memory file-like object
image_buffer = BytesIO()
if mswindows.windows():
image.convert("RGB").save(image_buffer, "BMP")
data = image_buffer.getvalue()[14:]

win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
win32clipboard.CloseClipboard()
image_buffer.close()
elif mswindows.macos():
try:
subprocess.run(
[
"osascript",
"-e",
'set the clipboard to (read (POSIX file "'
+ file_in
+ '") as JPEG picture)',
]
)
module_logger.debug(
"Successful copied result into clipboard under MacOS: %s", file_in
)
except:
module_logger.debug(
"Failed copied result into clipboard under MacOS: %s", file_in
)


def only_numbers(char):
Expand Down
2 changes: 1 addition & 1 deletion fotokilof/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
"""

__version__ = "5.0.1"
__version__ = "5.0.2"
__author__ = "Tomasz Łuczak"
__email__ = "[email protected]"
__appname__ = "FotoKilof"
Expand Down

0 comments on commit b486054

Please sign in to comment.