Almanik Compressor docs
Everything you need to install, use, understand and extend Almanik Compressor, the desktop app that compresses whole folders of videos and images while keeping their structure intact.
Introduction
Almanik Compressor is a cross-platform desktop application built with Electron. You give it folders, files or zip archives, and it writes a compressed copy of everything to a destination folder you choose.
- Bulk by default: drag & drop entire directory trees, not just single files.
- Structure-preserving: every subfolder, file name and empty directory is reproduced.
- Videos are compressed with ffmpeg, and images with sharp (libvips). Both are bundled.
- Zip-aware: archives are opened, their contents compressed, and then re-zipped or extracted.
- Three presets: High quality, Balanced and Smallest size.
- Local and private: no network access, no accounts, no telemetry.
Your originals are never modified. Almanik only reads sources and writes into the destination folder.
Quick start
- Install and launchDownload the AppImage or .deb from the Releases page, or run from source.
- Add inputsDrag folders, files or
.ziparchives onto the drop zone, or click Add folder… / Add files…. - Choose a destinationClick Choose destination… and pick (or create) an output folder.
- Pick a quality presetBalanced is selected by default. Tick Extract zip files if you want archives unpacked rather than re-zipped.
- Press StartEach file appears in the log with its before → after size. When the job ends you get a summary of the total saving.
Installation
Ready-made installers for Linux are published on GitHub Releases. Other platforms can run the app from source or build their own installer.
AppImage (any Linux distro)
A single portable executable that needs no installation.
$ chmod +x Almanik.Compressor-1.0.0.AppImage $ ./Almanik.Compressor-1.0.0.AppImage --no-sandbox
The --no-sandbox flag is needed because AppImages cannot ship Chromium's setuid sandbox helper. If the AppImage won't start at all, install FUSE 2 (for example sudo apt install libfuse2).
Debian / Ubuntu (.deb)
$ sudo apt install ./almanik-compressor_1.0.0_amd64.debThis adds Almanik Compressor to your applications menu. Remove it with sudo apt remove almanik-compressor.
Run from source
Requirements: Node.js 18+ and npm. Works on Linux, Windows and macOS.
$ git clone https://github.com/SHIBINSHA02/almanik.git $ cd almanik $ npm install $ npm start
npm install downloads a platform-specific ffmpeg binary (ffmpeg-static) and sharp's native libvips build, so no system ffmpeg is required.
System requirements
| Requirement | |
|---|---|
| OS | Linux x64 (release builds). Windows and macOS when built from source. |
| CPU | Any modern 64-bit CPU. More cores mean faster video encoding. |
| Disk | Space for the compressed output, plus temporary space on the destination drive for extracting zip archives. |
| Node.js | 18 or newer (source builds only). |
The interface
Almanik uses a single window (900 × 700 by default, minimum 700 × 560) with no menu bar. From top to bottom:
| Element | What it does |
|---|---|
| Drop zone | Drop folders or files here. Highlights while you drag over it. |
| Add folder… / Add files… | Native pickers. Both allow multiple selection. |
| Sources line | Shows how many items are queued and their names. |
| Choose destination… | Picks the output folder (you can create a new one in the dialog). |
| Extract zip files | When ticked, archives become plain folders instead of being re-zipped. |
| Quality | Preset selector: High quality, Balanced (default) or Smallest size. |
| Clear | Empties the input list and log. Disabled while a job is running. |
| Start / Cancel | Start becomes available once you have at least one input and a destination. While a job runs it turns into Cancel. |
| Progress bar | Overall progress: finished files / total files. |
| Log | One row per file with live status, newest at the top. |
| Summary | Totals once the job ends: files, size before → after, % saved and failures. |
Adding files & folders
You can mix folders, individual files and zip archives in one job. Duplicates are ignored.
- Drag & drop works for both files and folders at once.
- Add folder… opens a directory picker, and Add files… opens a file picker. They are separate buttons because Linux file dialogs can't select files and folders in the same dialog.
- If a drop isn't recognised (rare on some desktop environments), the sources line says so. Use the buttons instead.
A dropped folder keeps its own name in the output (dropping /home/me/photos produces <destination>/photos/…). A dropped file lands directly in the destination root.
Choosing a destination
All output is written into the destination folder. Rules:
- The destination cannot be the same folder as a source. The job fails with “Destination cannot be the same folder as a source.”
- The destination may be inside a source. It is skipped while scanning, so output is never re-read as input.
- The folder is created if it doesn't exist. Existing files with the same relative path are overwritten.
- Temporary zip work happens in
<destination>/.almanik-tmpand is deleted when the job ends.
Quality presets
Presets trade file size for fidelity. The same preset applies to every file in the job.
| Preset | Key | H.264 CRF | VP9 CRF | Audio | Image quality | Max image size |
|---|---|---|---|---|---|---|
| High quality | high | 23 | 27 | 128 kbps | 85 | Unchanged |
| Balanced (default) | balanced | 28 | 32 | 96 kbps | 75 | 2560 px |
| Smallest size | small | 32 | 36 | 64 kbps | 60 | 1920 px |
What is CRF?
Constant Rate Factor is ffmpeg's quality-targeted mode. Lower numbers mean higher quality and bigger files.Each +6 roughly halves the bitrate for H.264. WebM files use VP9, whose CRF scale differs, so Almanik adds 4 to the preset value.
Which one should I use?
- High quality: footage and photos you may still edit, print or present.
- Balanced: personal libraries and project archives. This is the best default.
- Smallest size: sharing, cloud backup, or media you rarely open.
Max image size is a bounding box. Images are scaled down to fit inside it with their aspect ratio kept, and they are never enlarged.
Zip archives
Every .zip among your inputs (including zips inside folders, and zips inside zips) is processed in one of two modes.
Default: re-zip
- Extract the archive into a private temporary folder under
<destination>/.almanik-tmp. - Compress its contents with the same rules as any folder.
- Re-pack it as a zip (deflate level 9) with the same name and relative path.
- If the new zip isn't smaller, copy the original zip instead.
- Delete the temporary folder right away to free space.
Extract mode
Tick Extract zip files (keep as folders, don't re-zip). Each archive becomes a folder with the zip's name minus .zip, filled with the compressed contents:
photos/bundle.zip → photos/bundle/ ├─ deep/zipped.jpg └─ readme.txt
Extraction needs free space on the destination drive for the full uncompressed archive. Temporary files deliberately live on the destination disk rather than in /tmp, which is often RAM-backed.
Progress & results
Each file moves through these states in the log:
| Status | Meaning |
|---|---|
video… | Started. The label is the detected kind: video, image, zip or other. |
42% | Live encoding progress (videos only), based on ffmpeg’s reported position against the duration. |
6.2 MB → 1.4 MB | Done. Before and after sizes. |
failed: … | Compression failed. The original was copied instead, and hovering shows the full error. |
The final summary looks like:
Done. 128 file(s), 4.21 GB → 1.07 GB (75% saved), 1 failedCancelling
Cancel stops the job immediately. Running ffmpeg processes are killed, partially written videos are deleted, no new files are started, and the temporary folder is removed. Files already finished stay in the destination. The summary starts with Cancelled.
Supported formats
Files are classified by extension (case-insensitive):
| Kind | Extensions | Handled by |
|---|---|---|
| Video | .mp4 .mov .mkv .avi .webm .m4v .flv .wmv .mpg .mpeg .3gp .ts | ffmpeg |
| Image | .jpg .jpeg .png .webp .avif .tif .tiff | sharp |
| Archive | .zip | yauzl + archiver |
| Other | everything else | copied unchanged |
Output files always keep their original name and extension.
Video encoding
Videos are re-encoded with the bundled ffmpeg. The codec depends on the output container:
| Extension | Container written | Video | Audio |
|---|---|---|---|
.webm | WebM | VP9 (libvpx-vp9), CRF + 4, quality mode (-b:v 0) | Opus |
.mkv | Matroska | H.264 (libx264), preset medium, yuv420p | AAC |
.mov | QuickTime + faststart | H.264 | AAC |
.avi | AVI | H.264 | AAC |
| all others | MP4 + faststart | H.264 | AAC |
- The first video stream and all audio streams are kept. Subtitle, data and extra video streams are dropped.
+faststartmoves the index to the front of MP4/MOV files so they start playing instantly when streamed.yuv420ppixel format ensures playback on virtually every device and browser.
Extensions like .m4v .flv .wmv .mpg .mpeg .3gp .ts are written as MP4 data under the original extension so paths stay identical. Modern players (VLC, mpv, browsers) detect this automatically, but very old or strict players may not.
Equivalent command for an .mp4 with the Balanced preset:
ffmpeg -y -i input.mp4 -map 0:v:0 -map 0:a? \ -c:v libx264 -crf 28 -preset medium -pix_fmt yuv420p \ -c:a aac -b:a 96k -movflags +faststart -f mp4 output.mp4
Image encoding
Images are processed with sharp (libvips). Each one is re-encoded in its own format:
| Format | Encoder settings |
|---|---|
| .jpg / .jpeg | MozJPEG, quality = preset |
| .png | Palette-quantised (lossy), compression level 9, quality = preset |
| .webp | WebP, quality = preset |
| .avif | AVIF, quality = preset |
| .tif / .tiff | TIFF with JPEG compression, quality = preset |
- EXIF orientation is applied, so rotated phone photos display upright everywhere.
- Images larger than the preset's max dimension are scaled down to fit. They are never upscaled.
- Metadata such as EXIF, GPS location and camera info is not carried over, which also helps privacy.
- Slightly damaged images are still processed where possible (
failOn: 'none').
Folder structure rules
- Each output path is
<destination>/<name of dropped item>/<path inside it>. - Empty folders are recreated.
- Symbolic links are skipped, which avoids loops and escaping the selected tree.
- Unsupported files are copied byte-for-byte, so the output is always complete.
- The destination folder is excluded from scanning when it sits inside a source.
Inputs: /home/me/project Destination: /mnt/backup /mnt/backup/project/a/photo.jpg (compressed) /mnt/backup/project/a/b/clip.mp4 (compressed) /mnt/backup/project/bundle.zip (contents compressed, re-zipped) /mnt/backup/project/notes.txt (copied) /mnt/backup/project/empty/ (recreated)
If two inputs share the same name (e.g. two different folders both called photos), their contents are merged in the destination, and identical relative paths overwrite each other. Rename one first if that matters.
Safety & error handling
Never bigger
After an image, video or re-built zip is written, its size is compared with the original. If it is not smaller, the original is copied over it, so totals can only shrink.
Failures don't stop the job
If any file fails (a corrupt video, an unreadable image), the partial output is deleted, the original is copied in its place, the failure counter goes up, and the job continues.
Zip-slip protection
Every entry in an archive is resolved against the extraction folder. Any entry that would escape it (e.g. ../../etc/passwd) aborts that archive with “Unsafe path in zip”, and the original zip is copied instead.
Input validation
- Every source must exist (“Not found: …”).
- The destination may not equal a source.
- Only one job can run at a time (“A job is already running.”).
Process isolation
The UI runs with contextIsolation: true, nodeIntegration: false and a strict Content-Security-Policy (default-src 'self'). It can only call the small set of functions exposed by the preload bridge.
Concurrency & performance
| Setting | Value | Why |
|---|---|---|
POOL | 3 | Files processed in parallel. This keeps I/O and image work overlapping. |
VIDEO_SLOTS | 2 | Maximum simultaneous ffmpeg encodes. Each one is already multi-threaded, so more would just thrash the CPU. |
- Zips are processed one entry tree at a time and their temp data is freed as soon as each archive is done.
- Video encoding dominates total time. For faster runs, use Smallest size (fewer bits to write) or run on a machine with more cores.
Architecture
Almanik follows Electron's secure three-layer model:
Renderer
src/renderer/- index.html
- renderer.js
- styles.css
Preload bridge
preload.js → window.api- contextBridge
- ipcRenderer.invoke
- webUtils.getPathForFile
Main process
main.js + src/core/- pipeline.js (Job)
- scanner · classify
- video · image · zip
- presets
Job flow
Project layout
almanik/ ├─ main.js # Electron main process, window + IPC handlers ├─ preload.js # Safe bridge exposing window.api ├─ src/ │ ├─ core/ │ │ ├─ pipeline.js # Job class: queue, workers, zips, stats │ │ ├─ scanner.js # Recursive walk, keeps relative paths │ │ ├─ classify.js # Extension → video | image | zip | other │ │ ├─ video.js # ffmpeg spawn + progress parsing │ │ ├─ image.js # sharp encoders per format │ │ ├─ zip.js # Safe extract + re-zip │ │ └─ presets.js # Quality presets │ └─ renderer/ # UI (HTML / CSS / JS) └─ test/run.js # End-to-end tests
Dependencies
| Package | Role |
|---|---|
electron | Desktop shell (dev dependency) |
ffmpeg-static | Bundled ffmpeg binary |
sharp | Image processing via libvips |
yauzl | Streaming zip reader |
archiver | Zip writer |
electron-builder | Packaging into AppImage / deb / nsis / dmg (dev dependency) |
IPC bridge API
The preload script exposes window.api to the renderer. All methods return Promises unless noted.
| Method | Returns | Description |
|---|---|---|
presets() | { [key]: label } | Available presets, e.g. { balanced: "Balanced" }. |
pickInputs(kind) | string[] | Native picker. kind is 'folder' or 'files'. Returns [] if cancelled. |
pickDestination() | string | null | Directory picker (can create folders). |
scan(inputs, dest) | { relPath, size }[] | Files that will be processed (used for the progress total). |
startJob(opts) | { stats } | { error } | Runs a job to completion. opts = { inputs, destination, preset, extractZips }. |
cancelJob() | void | Cancels the running job. |
pathsFromDrop(files) | string[] | Synchronous. Converts a drop event's FileList into absolute paths. |
onEvent(cb) | void | Subscribe to job events. |
const res = await window.api.startJob({ inputs: ['/home/me/videos'], destination: '/mnt/backup', preset: 'balanced', // 'high' | 'balanced' | 'small' extractZips: false, }); if (res.error) console.error(res.error); else console.log(res.stats); // { files, failed, before, after, cancelled }
Job events
The main process sends job-event messages while a job runs:
| Event | Payload |
|---|---|
| File started | { type: 'file', rel, kind, status: 'start' } |
| Video progress | { type: 'file', rel, kind, status: 'progress', progress } |
| File done | { type: 'file', rel, kind, status: 'done', before, after } |
| File failed | { type: 'file', rel, kind, status: 'error', error } |
| Job finished | { type: 'done', stats: { files, failed, before, after, cancelled } } |
rel is the file's relative path, kind is video | image | zip | other, progress is 0–1, and sizes are in bytes. Files inside zips emit events with paths relative to the archive.
Core modules
The src/core modules have no Electron dependency and can be used from plain Node.js, for scripts, CLIs or servers.
const { Job } = require('./src/core/pipeline'); const job = new Job({ inputs: ['/data/raw'], destination: '/data/compressed', preset: 'small', extractZips: false, onEvent: ev => ev.status === 'done' && console.log(ev.rel, ev.before, '→', ev.after), }); process.on('SIGINT', () => job.cancel()); const stats = await job.run();
| Export | Signature | Notes |
|---|---|---|
Job | new Job({ inputs, destination, preset, extractZips, onEvent }) | run() → stats, cancel(), validate() throws on bad input. Unknown presets fall back to balanced. |
scan | scan(inputs, exclude?) | Returns { absPath, relPath, size } or { absPath, relPath, isEmptyDir: true }. |
classify | classify(file) | 'video' | 'image' | 'zip' | 'other' |
compressVideo | compressVideo(src, dest, preset, onProgress) | Returns { promise, kill }. |
compressImage | compressImage(src, dest, preset) | Promise. |
extractZip | extractZip(zipPath, destDir) | Zip-slip safe extraction. |
zipDirectory | zipDirectory(srcDir, zipPath) | Deflate level 9. |
PRESETS | { high, balanced, small } | { label, crf, audioKbps, imageQuality, maxDim } |
Adding a custom preset
Add an entry to src/core/presets.js. It shows up in the UI automatically.
const PRESETS = { // ... archive: { label: 'Archive (tiny)', crf: 35, audioKbps: 48, imageQuality: 50, maxDim: 1280 }, };
Testing
$ npm testThe end-to-end suite (test/run.js) generates real media with sharp and ffmpeg and checks that:
- Folder structure, including empty folders, is preserved exactly.
- Images and videos come out smaller.
- Zips are rebuilt with smaller contents and the same entries.
- Extract mode turns zips into compressed folders.
- Zip-slip archives are rejected and nothing escapes.
- A corrupt video is counted as failed, but the original is kept and the job finishes.
- A destination inside the source works and isn't re-scanned, while a destination equal to the source is rejected.
The zip-slip test builds a malicious archive with python3, so make sure it is on your PATH.
Building installers
$ npm run distelectron-builder writes installers to dist/. Build each target on its own OS:
| Platform | Targets |
|---|---|
| Linux | AppImage, deb |
| Windows | NSIS installer |
| macOS | DMG |
Native binaries (ffmpeg-static, ffprobe-static, sharp, @img/*) are listed in asarUnpack so they can be executed from the packaged app. At runtime the ffmpeg path is rewritten from app.asar to app.asar.unpacked.
Troubleshooting
| Problem | Solution |
|---|---|
| AppImage exits immediately | Run it with --no-sandbox, and install libfuse2 if your distro lacks FUSE 2. |
| Start button is disabled | Add at least one input and choose a destination. |
| “Drop was not recognised” | Your desktop environment didn’t pass file paths. Use Add folder… / Add files… instead. |
| “Destination cannot be the same folder as a source.” | Pick a different output folder. A subfolder of the source is fine. |
| A file shows “failed” | It is probably corrupt or unsupported. The original was copied unchanged. Hover the message for the full ffmpeg/sharp error. |
| Output size equals the input size | The file was already well compressed, so Almanik kept the original. |
| A .wmv / .flv / .3gp won’t play after compression | It now contains MP4 data. Use VLC/mpv, or rename the file to .mp4. |
| Disk filled up during a zip job | Zips are extracted on the destination drive. Free up space or use extract mode, and leftover .almanik-tmp folders can be deleted safely. |
| “A job is already running.” | Wait for the current job to finish or press Cancel. |
Still stuck? Open an issue on GitHub with your OS, the file type and the error text.
FAQ
Will Almanik change or delete my original files?
No. Almanik only reads your sources and writes compressed copies into the destination folder you choose. It refuses to run if the destination is the same folder as a source.
Does it upload anything to the internet?
Never. ffmpeg and sharp are bundled inside the app, and all processing happens locally on your CPU. It works fully offline.
What happens to files it can't compress?
Documents, audio and any other unsupported file types are copied to the destination unchanged, so the output folder is always a complete copy of the input.
Can the output ever be bigger than my original?
No. After each file is compressed, Almanik compares sizes. If the new file isn't smaller, the original is kept instead. This applies to images, videos and re-built zip files.
Can I put the destination inside the source folder?
Yes. The destination folder is automatically skipped while scanning, so the output is never re-processed as input.
Is there a Windows or macOS version?
Windows (NSIS installer) and macOS (DMG) targets are configured. Build them on those systems with npm run dist, or run from source with npm start. Ready-made releases currently cover Linux.
Is there an Android app?
No. Almanik is a desktop application built with Electron, so there is no .apk.
License & credits
Almanik Compressor is released under the MIT License © 2026 SHIBINSHA. You may use, copy, modify and distribute it freely, provided the copyright notice is kept.
It builds on excellent open-source work: Electron, FFmpeg (via ffmpeg-static), libvips (via sharp), yauzl and archiver. Note that FFmpeg and its codecs carry their own licenses (LGPL/GPL).