Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
| system:linux:workstation:thundar-compress-images [2026/09/27 20:07] – removed - external edit (Unknown date) 127.0.0.1 | system:linux:workstation:thundar-compress-images [2026/09/27 20:07] (current) – ↷ Page moved from self:thundar-compress-images to system:linux:workstation:thundar-compress-images ilyasa | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Custom Images Compress untuk filemanager thundar ====== | ||
| + | I HATE TO OPEN ILOVOIMAGES EVERYTIME I NEED TO COMPESS IMAGE, THATS WHY IAM MAKING THIS. | ||
| + | |||
| + | ===== Install Tools Compress ===== | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Buat Script Compress ===== | ||
| + | |||
| + | < | ||
| + | mkdir -p ~/ | ||
| + | nano ~/ | ||
| + | </ | ||
| + | |||
| + | Isi dengan: | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | # | ||
| + | # compress-image.sh | ||
| + | # Compress JPG/PNG images into new files without modifying the originals. | ||
| + | # Designed to be used with a Thunar Custom Action using selected files (%F). | ||
| + | # | ||
| + | # Requirements: | ||
| + | # Install with: | ||
| + | # sudo apt install jpegoptim optipng pngquant | ||
| + | |||
| + | set -uo pipefail | ||
| + | |||
| + | JPEG_QUALITY=80 | ||
| + | SUFFIX=" | ||
| + | LOG_TAG=" | ||
| + | |||
| + | count_ok=0 | ||
| + | count_fail=0 | ||
| + | count_skip=0 | ||
| + | |||
| + | notify() { | ||
| + | if command -v notify-send >/ | ||
| + | notify-send " | ||
| + | fi | ||
| + | } | ||
| + | |||
| + | compress_jpeg() { | ||
| + | local input=" | ||
| + | local output=" | ||
| + | |||
| + | cp -- " | ||
| + | |||
| + | if jpegoptim --max=" | ||
| + | return 0 | ||
| + | fi | ||
| + | |||
| + | rm -f -- " | ||
| + | return 1 | ||
| + | } | ||
| + | |||
| + | compress_png() { | ||
| + | local input=" | ||
| + | local output=" | ||
| + | local ok=true | ||
| + | |||
| + | cp -- " | ||
| + | |||
| + | optipng -quiet -o5 " | ||
| + | pngquant --force --ext .png --skip-if-larger " | ||
| + | |||
| + | if [ " | ||
| + | return 0 | ||
| + | fi | ||
| + | |||
| + | rm -f -- " | ||
| + | return 1 | ||
| + | } | ||
| + | |||
| + | if [ " | ||
| + | notify "No files selected." | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | for file in " | ||
| + | if [ ! -f " | ||
| + | echo " | ||
| + | count_skip=$((count_skip + 1)) | ||
| + | continue | ||
| + | fi | ||
| + | |||
| + | filename=" | ||
| + | directory=" | ||
| + | |||
| + | extension=" | ||
| + | name=" | ||
| + | ext_lower=" | ||
| + | |||
| + | case " | ||
| + | jpg|jpeg|png) | ||
| + | output=" | ||
| + | |||
| + | # Avoid overwriting an existing compressed file. | ||
| + | if [ -e " | ||
| + | echo " | ||
| + | count_skip=$((count_skip + 1)) | ||
| + | continue | ||
| + | fi | ||
| + | |||
| + | if [ " | ||
| + | if compress_jpeg " | ||
| + | count_ok=$((count_ok + 1)) | ||
| + | echo " | ||
| + | else | ||
| + | count_fail=$((count_fail + 1)) | ||
| + | fi | ||
| + | else | ||
| + | if compress_png " | ||
| + | count_ok=$((count_ok + 1)) | ||
| + | echo " | ||
| + | else | ||
| + | count_fail=$((count_fail + 1)) | ||
| + | fi | ||
| + | fi | ||
| + | ;; | ||
| + | *) | ||
| + | echo " | ||
| + | count_skip=$((count_skip + 1)) | ||
| + | ;; | ||
| + | esac | ||
| + | done | ||
| + | |||
| + | summary=" | ||
| + | echo " | ||
| + | notify " | ||
| + | </ | ||
| + | |||
| + | Kasih permission execute: | ||
| + | |||
| + | < | ||
| + | |||
| + | ===== Tambah Custom Action di Thunar ===== | ||
| + | |||
| + | Buka Thunar, lalu: | ||
| + | |||
| + | Edit → Configure custom actions... | ||
| + | Klik tombol + (Add) | ||
| + | |||
| + | Di tab Basic: | ||
| + | |||
| + | * Name: Compress Image | ||
| + | * Description: | ||
| + | * Command: / | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | Di tab Appearance Conditions: | ||
| + | |||
| + | * File Pattern: *.jpg; | ||
| + | * Centang Image Files | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ===== Hasil ===== | ||
| + | {{ : | ||
| + | |||
| + | {{ : | ||
| + | |||