venkatesh commited on
Commit
da93e5f
·
1 Parent(s): 4747ffe

background to transparent under the processed images for tab5

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -3085,7 +3085,13 @@ def process_files(input_folder, marken_index, output_root):
3085
 
3086
  if file.suffix.lower() in ALLOWED_IMAGE_EXTENSIONS:
3087
  with PILImage.open(file) as img:
3088
- img.convert("RGB").save(ziel, format='PNG')
 
 
 
 
 
 
3089
  else:
3090
  shutil.copy2(file, ziel)
3091
 
@@ -3093,7 +3099,6 @@ def process_files(input_folder, marken_index, output_root):
3093
  file_to_factorgroup[neuer_name] = subfolder.name
3094
 
3095
  return renamed_files_by_folder_and_marke, file_to_factorgroup
3096
-
3097
  def brand_renamer_tool():
3098
  st.header("Advanced Brand File Processor")
3099
  st.markdown("Automatically rename and organize brand assets with numbering and generate reports.")
 
3085
 
3086
  if file.suffix.lower() in ALLOWED_IMAGE_EXTENSIONS:
3087
  with PILImage.open(file) as img:
3088
+ # Preserve transparency instead of converting to RGB
3089
+ if img.mode in ('RGBA', 'LA') or (img.mode == 'P' and 'transparency' in img.info):
3090
+ # If image already has transparency, preserve it
3091
+ img.save(ziel, format='PNG')
3092
+ else:
3093
+ # For images without transparency, convert to RGBA to allow transparency
3094
+ img.convert("RGBA").save(ziel, format='PNG')
3095
  else:
3096
  shutil.copy2(file, ziel)
3097
 
 
3099
  file_to_factorgroup[neuer_name] = subfolder.name
3100
 
3101
  return renamed_files_by_folder_and_marke, file_to_factorgroup
 
3102
  def brand_renamer_tool():
3103
  st.header("Advanced Brand File Processor")
3104
  st.markdown("Automatically rename and organize brand assets with numbering and generate reports.")