2 init gimp example

This commit is contained in:
tsuky_chen
2024-01-12 16:07:55 +08:00
parent b30d87bba8
commit e79235f568
4 changed files with 139 additions and 0 deletions

View File

@@ -9,3 +9,4 @@ from .table import check_sheet_list, check_xlsx_freeze, check_xlsx_zoom
from .table import compare_table
from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, compare_images, compare_audios, \
compare_videos
from .gimp import increase_saturation, decrease_brightness

View File

@@ -20,3 +20,57 @@ def get_gimp_export_path():
# Handle the case where the configuration file is not found
print("GIMP configuration file not found")
return False
from PIL import Image, ImageChops, ImageStat
def calculate_saturation(image):
# convert the image to HSV mode
hsv_image = image.convert("HSV")
saturation_channel = hsv_image.split()[1]
# calculate the mean saturation level
stat = ImageStat.Stat(saturation_channel)
mean_saturation = stat.mean[0]
return mean_saturation
def increase_saturation(image1_path, image2_path):
image1 = Image.open(image1_path)
image2 = Image.open(image2_path)
# calculate the saturation level of each image
saturation1 = calculate_saturation(image1)
saturation2 = calculate_saturation(image2)
return 1 if saturation1 < saturation2 else 0
def calculate_brightness(image):
# Convert the image to grayscale mode
grayscale_image = image.convert("L")
# Get the image data
pixels = list(grayscale_image.getdata())
brightness = sum(pixels) / len(pixels)
return brightness
def decrease_brightness(image1_path, image2_path):
image1 = Image.open(image1_path)
image2 = Image.open(image2_path)
brightness1 = calculate_brightness(image1)
brightness2 = calculate_brightness(image2)
return 1 if brightness1 > brightness2 else 0
if __name__ == "__main__":
# 输入两张图片的路径
image1_path = "../Downloads/1.png"
image2_path = "../Downloads/edited_darker.png"
# 比较图片亮度
decrease_brightness(image1_path, image2_path)
# 比较图片饱和度
increase_saturation(image1_path, image2_path)

View File

@@ -0,0 +1,42 @@
{
"id": "7a4deb26-d57d-4ea9-9a73-630f66a7b568",
"snapshot": "gimp",
"instruction": "Make my picture less bright, please.",
"source": "https://www.quora.com/How-do-I-edit-a-photo-in-GIMP",
"config": [
{
"type": "download",
"parameters": {
"files": [
{
"url": "https://drive.usercontent.google.com/download?id=1SIvX9Wimyw6i2UvnoLTNDHIObvDLAsIM&export=download&authuser=0&confirm=t&uuid=a48447ab-13a2-421f-9662-6ffff8f6f6d5&at=APZUnTVRxofs822XxgEv33WwYCkb:1705046264363",
"path": "Desktop/1.png"
}
]
}
},
{
"type": "open",
"parameters": {
"path": "Desktop/View_Person_Organizational_Summary.docx"
}
}
],
"trajectory": "trajectories/",
"related_apps": [
"gimp"
],
"evaluator": {
"func": "decrease_brightness",
"result": {
"type": "vm_file",
"path": "Desktop/1.png",
"dest": "1.png"
},
"expected": {
"type": "vm_file",
"path": "Desktop/edited_darker.png",
"dest": "edited_darker.png"
}
}
}

View File

@@ -0,0 +1,42 @@
{
"id": "554785e9-4523-4e7a-b8e1-8016f565f56a",
"snapshot": "gimp",
"instruction": "Could you help me increase the saturation of my photo to make it more colorful?",
"source": "https://www.quora.com/How-do-I-edit-a-photo-in-GIMP",
"config": [
{
"type": "download",
"parameters": {
"files": [
{
"url": "https://drive.usercontent.google.com/download?id=1SIvX9Wimyw6i2UvnoLTNDHIObvDLAsIM&export=download&authuser=0&confirm=t&uuid=a48447ab-13a2-421f-9662-6ffff8f6f6d5&at=APZUnTVRxofs822XxgEv33WwYCkb:1705046264363",
"path": "Desktop/1.png"
}
]
}
},
{
"type": "open",
"parameters": {
"path": "Desktop/View_Person_Organizational_Summary.docx"
}
}
],
"trajectory": "trajectories/",
"related_apps": [
"gimp"
],
"evaluator": {
"func": "increase_saturation",
"result": {
"type": "vm_file",
"path": "Desktop/1.png",
"dest": "1.png"
},
"expected": {
"type": "vm_file",
"path": "Desktop/edited_colorful.png",
"dest": "edited_colorful.png"
}
}
}