@@ -430,11 +430,11 @@ def check_image_size(src_path, rule):
|
|||||||
img = Image.open(src_path)
|
img = Image.open(src_path)
|
||||||
|
|
||||||
# Check the size
|
# Check the size
|
||||||
if rule["height"] is not None:
|
if rule.get("height", None) is not None:
|
||||||
height_same = img.size[1] == rule["height"]
|
height_same = img.size[1] == rule["height"]
|
||||||
else:
|
else:
|
||||||
height_same = True
|
height_same = True
|
||||||
if rule["width"] is not None:
|
if rule.get("width", None) is not None:
|
||||||
width_same = img.size[0] == rule["width"]
|
width_same = img.size[0] == rule["width"]
|
||||||
else:
|
else:
|
||||||
width_same = True
|
width_same = True
|
||||||
@@ -568,3 +568,51 @@ def check_image_file_size(src_path, rule):
|
|||||||
return 1.0
|
return 1.0
|
||||||
else:
|
else:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
actual_config_path = "../../../cache/sessionrc_test"
|
||||||
|
rule = {
|
||||||
|
"key": "hide-docks",
|
||||||
|
"value": "no"
|
||||||
|
}
|
||||||
|
print(check_config_status(actual_config_path, rule))
|
||||||
|
|
||||||
|
actual_config_path = "../../../cache/action-history_test"
|
||||||
|
rule = {
|
||||||
|
"key": ["history-item", "\"filters-vignette\""],
|
||||||
|
"value": "1"
|
||||||
|
}
|
||||||
|
print(check_config_status(actual_config_path, rule))
|
||||||
|
|
||||||
|
actual_config_path = "../../../cache/gimprc_test"
|
||||||
|
rule = {
|
||||||
|
"key": "undo-levels",
|
||||||
|
"value": "100"
|
||||||
|
}
|
||||||
|
print(check_config_status(actual_config_path, rule))
|
||||||
|
|
||||||
|
src_path = "../../../cache/734d6579-c07d-47a8-9ae2-13339795476b/green_background_with_object.png"
|
||||||
|
tgt_path = "../../../cache/734d6579-c07d-47a8-9ae2-13339795476b/white_background_with_object.png"
|
||||||
|
print(check_green_background(src_path, tgt_path))
|
||||||
|
|
||||||
|
tgt_path = "../../../cache/f4aec372-4fb0-4df5-a52b-79e0e2a5d6ce/Triangle_In_The_Middle.png"
|
||||||
|
print(check_triangle_position(tgt_path))
|
||||||
|
|
||||||
|
src_path = "../../../cache/bb7db4c2-30b5-4be7-8dd7-b8c4ec7d3108/anmi_sharper.png"
|
||||||
|
tgt_path = "../../../cache/bb7db4c2-30b5-4be7-8dd7-b8c4ec7d3108/anmi.png"
|
||||||
|
print(check_sharper(src_path, tgt_path))
|
||||||
|
|
||||||
|
src_path = "../../../cache/3c8f201a-009d-4bbe-8b65-a6f8b35bb57f/compressed.jpeg"
|
||||||
|
rule = {
|
||||||
|
"max_size": 500000
|
||||||
|
}
|
||||||
|
print(check_image_file_size(src_path, rule))
|
||||||
|
|
||||||
|
src_path = "../../../cache/d16c99dc-2a1e-46f2-b350-d97c86c85c15/resized.png"
|
||||||
|
tgt_path = "../../../cache/d16c99dc-2a1e-46f2-b350-d97c86c85c15/dog_with_background.png"
|
||||||
|
rule = {
|
||||||
|
"height": 512
|
||||||
|
}
|
||||||
|
print(check_image_size(src_path, rule))
|
||||||
|
print(check_structure_sim_resized(src_path, tgt_path))
|
||||||
@@ -86,13 +86,14 @@
|
|||||||
],
|
],
|
||||||
"func": [
|
"func": [
|
||||||
"check_image_size",
|
"check_image_size",
|
||||||
"check_structure_sim"
|
"check_structure_sim_resized"
|
||||||
],
|
],
|
||||||
"expected": [
|
"expected": [
|
||||||
{
|
{
|
||||||
"type": "vm_file",
|
"type": "rule",
|
||||||
"path": "/home/user/Desktop/dog_with_background.png",
|
"rules": {
|
||||||
"dest": "dog_with_background.png"
|
"height": 512
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "vm_file",
|
"type": "vm_file",
|
||||||
@@ -102,10 +103,9 @@
|
|||||||
],
|
],
|
||||||
"result": [
|
"result": [
|
||||||
{
|
{
|
||||||
"type": "rule",
|
"type": "vm_file",
|
||||||
"rules": {
|
"path": "/home/user/Desktop/dog_with_background.png",
|
||||||
"height": 512
|
"dest": "dog_with_background.png"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "vm_file",
|
"type": "vm_file",
|
||||||
|
|||||||
Reference in New Issue
Block a user