File size: 1,159 Bytes
2f22ac0
d228bd9
62fc38e
347fa2e
2f22ac0
d228bd9
 
 
 
1c4ec67
7fcf6be
 
0000d05
 
 
 
 
b135ade
0000d05
 
 
 
9484460
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
import os
import sys
from animationPipeline import animateLogo


uploaded_file = st.file_uploader('Please upload your SVG')
if uploaded_file is not None:
    file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}
    if 'svg' not in uploaded_file.type:
      st.write(uploaded_file.type)
      st.write('Please upload an SVG file.')
    else:
      st.write(file_details)
      if not os.path.exists('tempDir'):
        os.mkdir('tempDir')
      path = os.path.join('tempDir', uploaded_file.name)
      targetPath = os.path.join('tempDir', uploaded_file.name[:-4]+"_animated.svg")
      with open(path,"wb") as f: 
        f.write(uploaded_file.getbuffer())         
      st.success("Saved File")
      sys.setrecursionlimit(1500)
      success = animateLogo(path, targetPath)
      if success:
        with open(targetPath, "rb") as file:
          st.write(file)
          st.download_button('Download animated SVG', data=file, file_name=uploaded_file.name[:-4]+"_animated.svg")
      else:
        st.write('This SVG cannot be animated due to limitations of the used DeepSVG library. Please use another file.')