Spaces:
Runtime error
Runtime error
Commit
·
29f88cf
1
Parent(s):
e47b7db
Subindo arquivos
Browse files- README.md +28 -7
- app.py +52 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,13 +1,34 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
-
license: ecl-2.0
|
11 |
---
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: image-inspector
|
3 |
+
emoji: 🔍
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: green
|
6 |
sdk: gradio
|
7 |
+
sdk_version: "4.12.0"
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
+
# Inspetor de Imagem 🔍
|
13 |
+
|
14 |
+
O Inspetor de Imagem é uma ferramenta que permite a você fazer o upload de uma imagem (.jpg, .png, .bmp, etc.) e exibir detalhes sobre ela, como formato, dimensões, profundidade de cor, DPI, tamanho do arquivo, timestamp de modificação e tipo de compressão.
|
15 |
+
|
16 |
+
## Funcionalidades
|
17 |
+
|
18 |
+
- Upload de imagem com visualização de detalhes em tempo real
|
19 |
+
- Suporte a diversos formatos de imagem
|
20 |
+
- Exibição de informações técnicas da imagem
|
21 |
+
- Interface de usuário simples e fácil de usar
|
22 |
+
|
23 |
+
## Como Usar
|
24 |
+
|
25 |
+
1. Acesse o aplicativo na Hugging Face Spaces.
|
26 |
+
2. Faça o upload de uma imagem clicando em "Upload de Imagem" ou arraste e solte o arquivo na área indicada.
|
27 |
+
3. Veja as informações da imagem aparecerem automaticamente abaixo do upload.
|
28 |
+
|
29 |
+
## Versão Teste 1 (25/04)
|
30 |
+
|
31 |
+
- Desenvolvedor: Ramon Mayor Martins
|
32 |
+
- Para sugestões ou relatórios de bugs, por favor, entre em contato pelo e-mail: [rmayormartins@gmail.com](mailto:rmayormartins@gmail.com)
|
33 |
+
|
34 |
+
|
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import time
|
3 |
+
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
+
import io
|
6 |
+
|
7 |
+
def image_inspector(uploaded_file):
|
8 |
+
file_size = os.path.getsize(uploaded_file.name)
|
9 |
+
|
10 |
+
if file_size < 1024:
|
11 |
+
readable_file_size = f"{file_size} bytes"
|
12 |
+
elif file_size < 1024**2:
|
13 |
+
readable_file_size = f"{file_size / 1024:.2f} KB"
|
14 |
+
else:
|
15 |
+
readable_file_size = f"{file_size / (1024**2):.2f} MB"
|
16 |
+
|
17 |
+
file_timestamp = time.ctime(os.path.getmtime(uploaded_file.name))
|
18 |
+
|
19 |
+
try:
|
20 |
+
with Image.open(uploaded_file.name) as image:
|
21 |
+
|
22 |
+
bit_depth = image.mode
|
23 |
+
num_channels = len(image.getbands())
|
24 |
+
bit_depth_info = f"{num_channels * 8}-bit" if bit_depth else 'Desconhecido'
|
25 |
+
|
26 |
+
details = {
|
27 |
+
"Formato": image.format or "Desconhecido",
|
28 |
+
"Modo": image.mode,
|
29 |
+
"Dimensões": image.size,
|
30 |
+
"Profundidade de Cor (Bit Depth)": bit_depth_info,
|
31 |
+
"DPI": image.info.get('dpi', 'Não disponível'),
|
32 |
+
"Tamanho do Arquivo": readable_file_size,
|
33 |
+
"Timestamp do Arquivo": file_timestamp,
|
34 |
+
"Tipo de Compressão": image.info.get('compression', 'Não disponível'),
|
35 |
+
"Bands": image.getbands()
|
36 |
+
}
|
37 |
+
except Exception as e:
|
38 |
+
return f"Ocorreu um erro ao processar a imagem: {e}"
|
39 |
+
|
40 |
+
formatted_details = "\n".join([f"{key}: {value}" for key, value in details.items()])
|
41 |
+
return formatted_details
|
42 |
+
|
43 |
+
iface = gr.Interface(
|
44 |
+
fn=image_inspector,
|
45 |
+
inputs=gr.File(label="Upload de Imagem"),
|
46 |
+
outputs="text",
|
47 |
+
title="Inspetor de Imagem",
|
48 |
+
description="Faça o upload de uma imagem (.jpg, .png, .bmp, etc.) e veja detalhes sobre ela."
|
49 |
+
)
|
50 |
+
|
51 |
+
if __name__ == "__main__":
|
52 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
Pillow
|
3 |
+
|