This application is a FastAPI service designed to convert PNG images, particularly full-page screenshots, into a custom .vic
format. This format offers unique advantages in terms of adaptive resizing and iframe embedding with smooth vertical scrolling.
The .vic
files are designed to address common challenges with full-page screenshots:
- Long screenshots are resized to fit standard screen sizes.
- Images become unreadable without zooming as they shrink excessively.
- Adaptive Resizing:
.vic
images automatically adjust to the width of screens or iframes, whether on mobile devices, tablets, or desktops.
- Integrated Scrolling:
- A vertical scroll is added to display the entire screenshot regardless of its height.
- Flexible Dimensions:
- Dimensions can be controlled via an iframe.
-
PNG β VIC Conversion
- Converts PNG images, especially screenshots, into the
.vic
format. - Automatically resizes images to adapt to screens or iframes.
- Converts PNG images, especially screenshots, into the
-
Metadata Extraction
- Extracts details such as original dimensions, file type (screenshot or regular image), and other information.
-
VIC File Preview
- Streams the PNG embedded in
.vic
files.
- Streams the PNG embedded in
-
Iframe Generation
- Generates an iframe to easily integrate
.vic
files into web pages.
- Generates an iframe to easily integrate
-
Conversion from a Public URL
- Downloads an image from its URL (e.g., a Google image) and converts it to
.vic
.
- Downloads an image from its URL (e.g., a Google image) and converts it to
git clone <repository-url>
cd <repository-directory>
Ensure Python 3.8+ is installed, then run:
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000
The application will be accessible at: http://<your-ip>:8000
Access the /convert
endpoint using a tool like Postman or the Swagger UI interface available at http://<your-ip>:8000/docs
.
- Parameters:
file
: A PNG image.for_iframe
(optional): Specifytrue
to optimize the file for an iframe.
The API will return a .vic
file ready for download.
Access /metadata
to extract metadata from a .vic
file.
- Steps:
- Upload a
.vic
file via POST. - Receive metadata such as:
- Original and adjusted dimensions.
- File type (regular image or screenshot).
- Aspect ratio.
- Image format.
- Upload a
Access /preview
to view the image embedded in a .vic
file.
- Steps:
- Upload a
.vic
file to receive the embedded PNG image.
- Upload a
Access /generate-iframe
and provide the public URL of a .vic
file to generate an HTML iframe.
- Example Request:
http://<your-ip>:8000/generate-iframe?file_url=http://<your-ip>:8000/static/sample.vic
- Example Response:
<iframe src="http://<your-ip>:8000/static/vic-viewer.html?file=http://<your-ip>:8000/static/sample.vic" width="560" height="315" frameborder="0" allowfullscreen></iframe>
Access /fetch-vic
and provide the URL of a public image (e.g., a Google image).
- Example Request:
http://<your-ip>:8000/fetch-vic?file_url=<image-url>
- The image will be downloaded and converted to
.vic
.
A feature-rich interface to display .vic
files and their metadata.
- Accessible at:
http://<your-ip>:8000/static/visionneuse.html
A minimalist interface tailored for iframes.
- Accessible at:
http://<your-ip>:8000/static/vic-viewer.html?file=<file-url>
To embed a .vic
image in a website:
<iframe
src="http://<your-ip>:8000/static/vic-viewer.html?file=http://<your-ip>:8000/static/sample.vic"
width="560"
height="315"
frameborder="0"
allowfullscreen>
</iframe>
.vic
files must be placed in thestatic
directory to be served correctly.
- If you embed the iframe on another site, configure the CORS headers accordingly.
FastAPI/
βββ __pycache__/ # Python cache for the project
βββ static/ # Static files for the project
β βββ index.html # HTML homepage
β βββ output.vic # Example of a .vic file
β βββ vic-viewer.html # HTML viewer for .vic files
βββ .env # Environment configuration file
βββ .gitignore # Git exclusions
βββ compare_sizes.py # Script to compare file sizes
βββ convert_to_my_format.py # CLI script to convert files to .vic format
βββ linode.vic.tar.gz # Example of a compressed .vic file
βββ main.py # Main application for FastAPI or FastAPI
βββ output.vic.tar.gz # Generated compressed .vic file
βββ Procfile # FastAPI deployment specifications
βββ read_my_format.py # Script to read and validate .vic files
βββ README.fr.md # Documentation in French
βββ README.md # Documentation in English
βββ requirements.txt # Python dependencies
βββ runtime.txt # Python version for FastAPI
βββ test1.vic # Test .vic file
βββ test1.vic.tar.gz # Compressed version of the test file
βββ visionneuse.html # Rich viewer for displaying .vic files