Silverbelt commited on
Commit
63e8f49
1 Parent(s): 1c6a170

add source file to the set, zoomed 400% + correct file type

Browse files
scripts/generate-icat-comparison-projects.py CHANGED
@@ -71,15 +71,17 @@ def get_image_dimensions(file_path):
71
  script_dir = os.path.dirname(os.path.abspath(__file__))
72
 
73
  # Construct the full path to the target directory
74
- base_dir = os.path.join(script_dir, '..', 'result', 'flux-dev')
75
 
76
  output_dir = os.path.join(script_dir, '..', 'output/icat_projects')
77
 
78
- if not os.path.exists(base_dir):
79
- print(f"The path {base_dir} does not exist!")
80
- sys.exit(1) # Exit the program with a non-zero status to indicate an error
81
- else:
82
- print(f"Searching for images in {base_dir}.")
 
 
83
 
84
  os.makedirs(output_dir, exist_ok=True)
85
 
@@ -90,15 +92,16 @@ pattern = re.compile(r'\d{5}')
90
  file_groups = defaultdict(list)
91
 
92
  # Walk through all subdirectories and files
93
- for root, dirs, files in os.walk(base_dir):
94
- for file in files:
95
- # Search for the five-digit number in the file name
96
- match = pattern.search(file)
97
- if match:
98
- # Get the five-digit number
99
- number = match.group()
100
- # Add the file (with its full path) to the corresponding group
101
- file_groups[number].append(os.path.join(root, file))
 
102
 
103
  # Fill JSON structure with grouped files
104
  for number, group in file_groups.items():
@@ -143,12 +146,18 @@ for number, group in file_groups.items():
143
  hex_id = uuid.uuid4().hex # Generate a unique hex ID for each file
144
  cleaned_path = os.path.abspath(file_path).replace('\\', '%5C').replace(':', '%3A')
145
  width, height = get_image_dimensions(file_path)
 
 
 
 
 
 
146
 
147
  # Example media entry
148
  media_entry = {
149
  "id": hex_id,
150
  "created": int(os.path.getctime(file_path) * 1000),
151
- "codec": "PNG",
152
  "bitrate": 0,
153
  "width": width,
154
  "height": height,
@@ -163,11 +172,11 @@ for number, group in file_groups.items():
163
  "name": file_name,
164
  "base": base_name,
165
  "originalBase": base_name,
166
- "extension": file_name.split('.')[-1],
167
- "format": "PNG",
168
  "x": 0,
169
  "y": 0,
170
- "z": 100,
171
  "startTime": 0,
172
  "thumbnails": [],
173
  "labelVisibility": {
 
71
  script_dir = os.path.dirname(os.path.abspath(__file__))
72
 
73
  # Construct the full path to the target directory
74
+ base_dirs = [os.path.join(script_dir, '..', 'source'), os.path.join(script_dir, '..', 'result')]
75
 
76
  output_dir = os.path.join(script_dir, '..', 'output/icat_projects')
77
 
78
+ for dir in base_dirs:
79
+ if not os.path.exists(dir):
80
+ print(f"The path {dir} does not exist!")
81
+ sys.exit(1) # Exit the program with a non-zero status to indicate an error
82
+
83
+
84
+ print(f"Searching for images in {base_dirs}.")
85
 
86
  os.makedirs(output_dir, exist_ok=True)
87
 
 
92
  file_groups = defaultdict(list)
93
 
94
  # Walk through all subdirectories and files
95
+ for dir in base_dirs:
96
+ for root, dirs, files in os.walk(dir):
97
+ for file in files:
98
+ # Search for the five-digit number in the file name
99
+ match = pattern.search(file)
100
+ if match:
101
+ # Get the five-digit number
102
+ number = match.group()
103
+ # Add the file (with its full path) to the corresponding group
104
+ file_groups[number].append(os.path.join(root, file))
105
 
106
  # Fill JSON structure with grouped files
107
  for number, group in file_groups.items():
 
146
  hex_id = uuid.uuid4().hex # Generate a unique hex ID for each file
147
  cleaned_path = os.path.abspath(file_path).replace('\\', '%5C').replace(':', '%3A')
148
  width, height = get_image_dimensions(file_path)
149
+ fileExt = file_name.split('.')[-1]
150
+
151
+ if "source" in file_path.lower():
152
+ zoomFactor = 400
153
+ else:
154
+ zoomFactor = 100
155
 
156
  # Example media entry
157
  media_entry = {
158
  "id": hex_id,
159
  "created": int(os.path.getctime(file_path) * 1000),
160
+ "codec": fileExt.upper(),
161
  "bitrate": 0,
162
  "width": width,
163
  "height": height,
 
172
  "name": file_name,
173
  "base": base_name,
174
  "originalBase": base_name,
175
+ "extension": fileExt,
176
+ "format": fileExt.upper(),
177
  "x": 0,
178
  "y": 0,
179
+ "z": zoomFactor,
180
  "startTime": 0,
181
  "thumbnails": [],
182
  "labelVisibility": {