update: added support for IMU and Lottie JSON
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
if (
|
||||
len(sys.argv) != 5
|
||||
or not sys.argv[1].endswith(".svg")
|
||||
or not os.path.isfile(sys.argv[1])
|
||||
or not os.path.isfile(sys.argv[2])
|
||||
):
|
||||
print('Proper usage "python app.py AA.svg /path/to/svg2png 400 100"')
|
||||
print('Proper usage "python app.py SVG_FILE SVG_PNG_PATH SIZE_IMAGE NUMBER_OF_TRIES"')
|
||||
raise ValueError(
|
||||
"POSSIBLE_PROBLEM - Missing or invalid input file or missing path to svg2png"
|
||||
)
|
||||
|
||||
try_number = int(sys.argv[4])
|
||||
image_size = sys.argv[3]
|
||||
svg2png_path = sys.argv[2]
|
||||
image_input = sys.argv[1]
|
||||
image_output = image_input.replace(".svg", ".png")
|
||||
|
||||
args = [svg2png_path, image_input, "-r", f"{image_size}x{image_size}"]
|
||||
sizes: dict = {}
|
||||
for i in range(try_number + 1):
|
||||
# if i % 100 == 0:
|
||||
# print(f"{i + 1}/{try_number + 1}")
|
||||
subprocess.call(args, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
new_size = os.path.getsize(image_output)
|
||||
if new_size in sizes:
|
||||
sizes[new_size] += 1
|
||||
else:
|
||||
sizes[new_size] = 1
|
||||
|
||||
sizes = dict(sorted(sizes.items(), key=lambda item: item[1], reverse=True))
|
||||
|
||||
if len(sizes) == 1:
|
||||
print(f"Not found problem with generating images, sizes - {str(sizes)}")
|
||||
else:
|
||||
print(
|
||||
f"POSSIBLE_PROBLEM - Converting svg to png is not reproducible - file sizes {str(sizes)}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
@@ -0,0 +1,38 @@
|
||||
[general]
|
||||
folder_with_files_to_check = "FilesToTest"
|
||||
problematic_files_path = "ProblematicSVG" # Where to store problematic files, in which conversion failed(e.g. due program crash)
|
||||
output_folder = "BrokenSVG" # Place where to save files(Input and output that show differences)
|
||||
ignored_files_path = "IgnoredSVG" # Place where to save ignored files
|
||||
timeout = 120
|
||||
limit_threads = 0 # 0 will use all available threads
|
||||
px_size_of_generated_file = 400
|
||||
ignore_conversion_step = false # Ignore step with conversion files from svg to png, just compare files
|
||||
ignore_similarity_checking_step = false # Useful to finding problems with generating files
|
||||
ignore_thorvg_not_supported_items = true # Thorvg not supports files with text, filters
|
||||
max_difference = 5 # Bigger similarity will show only broken files that are completely different, looks that 0-100 is quite reasonable range
|
||||
limit_files = 0 # Limit checked files, useful if you are just wanting to check how app works, 0 will remove limit of checked files
|
||||
remove_files_from_output_folder_at_start = true # Useful if you run app with different settings and you don't want to remove files one by one
|
||||
debug_show_always_output = false # Allows to find broken files
|
||||
return_error_when_finding_invalid_files = false # When finding invalid files(broken or problematic) app will close with status 1
|
||||
remove_problematic_files_after_copying = false # Remove from output folder problematic svg files
|
||||
remove_broken_files_after_copying = false # Remove from output folder broken svg files
|
||||
remove_ignored_files_after_copying = false # Removes not supported folders after copying
|
||||
remove_generated_png_files_at_end = false # Remove all png from output folder at end
|
||||
lottie_path = ""
|
||||
lottie_broken_files_path = ""
|
||||
lottie_test = false
|
||||
thorvg_path = ""
|
||||
thorvg_broken_files_path = ""
|
||||
thorvg_test = false
|
||||
|
||||
[first_tool]
|
||||
name = "thorvg_pr"
|
||||
path = "./build/src/tools/svg2png/svg2png"
|
||||
png_name_ending = "_thorvg_pr.png"
|
||||
arguments = "{FILE} -r {SIZE}x{SIZE} -b ffffff"
|
||||
|
||||
[other_tool]
|
||||
name = "thorvg_develop"
|
||||
path = "./thorvg_develop/build/src/tools/svg2png/svg2png"
|
||||
png_name_ending = "_thorvg_develop.png"
|
||||
arguments = "{FILE} -r {SIZE}x{SIZE} -b ffffff"
|
||||
@@ -0,0 +1,39 @@
|
||||
[general]
|
||||
folder_with_files_to_check = "FilesToTest"
|
||||
problematic_files_path = "ProblematicSVG" # Where to store problematic files, in which conversion failed(e.g. due program crash)
|
||||
output_folder = "BrokenSVG" # Place where to save files(Input and output that show differences)
|
||||
ignored_files_path = "IgnoredSVG" # Place where to save ignored files
|
||||
timeout = 120
|
||||
limit_threads = 0 # 0 will use all available threads
|
||||
px_size_of_generated_file = 400
|
||||
ignore_conversion_step = false # Ignore step with conversion files from svg to png, just compare files
|
||||
ignore_similarity_checking_step = false # Useful to finding problems with generating files
|
||||
ignore_thorvg_not_supported_items = true # Thorvg not supports files with text, filters
|
||||
max_difference = 5 # Bigger similarity will show only broken files that are completely different, looks that 0-100 is quite reasonable range
|
||||
limit_files = 0 # Limit checked files, useful if you are just wanting to check how app works, 0 will remove limit of checked files
|
||||
remove_files_from_output_folder_at_start = true # Useful if you run app with different settings and you don't want to remove files one by one
|
||||
debug_show_always_output = false # Allows to find broken files
|
||||
return_error_when_finding_invalid_files = false # When finding invalid files(broken or problematic) app will close with status 1
|
||||
remove_problematic_files_after_copying = false # Remove from output folder problematic svg files
|
||||
remove_broken_files_after_copying = false # Remove from output folder broken svg files
|
||||
remove_ignored_files_after_copying = false # Removes not supported folders after copying
|
||||
remove_generated_png_files_at_end = false # Remove all png from output folder at end
|
||||
lottie_path = ""
|
||||
lottie_broken_files_path = ""
|
||||
lottie_test = false
|
||||
thorvg_path = "./build/src/tools/svg2png/svg2png"
|
||||
thorvg_broken_files_path = "BrokenFILES"
|
||||
thorvg_test = true
|
||||
|
||||
[first_tool]
|
||||
name = "thorvg_pr"
|
||||
path = "./build/src/tools/svg2png/svg2png"
|
||||
png_name_ending = "_thorvg_pr.png"
|
||||
arguments = "{FILE} -r {SIZE}x{SIZE} -b ffffff"
|
||||
|
||||
[other_tool]
|
||||
name = "thorvg_develop"
|
||||
path = "./thorvg_develop/build/src/tools/svg2png/svg2png"
|
||||
png_name_ending = "_thorvg_develop.png"
|
||||
arguments = "{FILE} -r {SIZE}x{SIZE} -b ffffff"
|
||||
|
||||
Reference in New Issue
Block a user