Sunday, June 29, 2025

Unable to install python3.11-venv on debian bookworm


I was getting some errors when I tried installing python3.11-venv on debian bookworm.
____________________________________________

Err:1 http://deb.debian.org/debian bookworm/main amd64 python3.11-venv amd64 3.11.2-6+deb12u5

404 Not Found [IP: 2a04:4e42:25::644 80]

E: Failed to fetch http://deb.debian.org/debian/pool/main/p/python3.11/python3.11-venv_3.11.2-6%2bdeb12u5_amd64.deb 404 Not Found [IP: 2a04:4e42:25::644 80]



E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

___________________________

How did I resolve the issue?

Edit your sources.list following this example on Debian wiki by adding this line:deb http://security.debian.org/debian-security bookworm-security main


Then run:sudo apt update && sudo apt dist-upgrade sudo apt install -y python3.11-venv

_________________

Resolving Gnome Calculator Issues on Debian 12 Bookworm

 If you're experiencing problems with the Gnome Calculator on Debian 12 Bookworm, you're not alone. Many users have encountered unexpected behavior or complete non-functionality with this essential utility. Fortunately, there's a simple fix that can resolve most issues.


The Quick Solution:

The magic command that can bring your Gnome Calculator back to life is:


$ dconf write /org/gnome/calculator/refresh-interval 0


References:
https://forums.debian.net/viewtopic.php?t=158572 


Saturday, May 3, 2025

Fixing Time Differences in Debian 12 with Dual Boot

If you're running Debian 12 and have it set up in a dual boot configuration with another operating system, you may have noticed that the system time is not consistent between the two. This can be a frustrating issue, but there's a simple command that can help resolve it.

Issue description

The problem often arises because different operating systems handle the system clock differently. Windows, for example, typically stores the time in the hardware clock as local time, while Linux distributions like Debian store it as UTC (Coordinated Universal Time). When you switch between the two, the system time can become out of sync.

The Fix

Fortunately, there's a command you can run in Debian 12 to fix this issue. Open a terminal and enter the following:

timedatectl set-local-rtc 1 --adjust-system-clock


This command tells Debian to treat the hardware clock as local time, and it will automatically adjust the system clock accordingly.

Here's a breakdown of what the command does:timedatectl is the command-line tool for managing the system clock and time zone.

  • set-local-rtc 1 tells Debian to treat the hardware clock as local time, rather than UTC.
  • --adjust-system-clock instructs Debian to update the system clock to match the hardware clock.

After running this command, your Debian 12 system should now be in sync with the time displayed in your other operating system when dual booting.

It's worth noting that this solution may not work in all cases, as the time discrepancy can sometimes be caused by other factors. If you're still experiencing issues, you may need to explore additional troubleshooting steps, such as checking your BIOS settings or adjusting the time zone configuration.

In any case, the timedatectl set-local-rtc 1 --adjust-system-clock command is a great starting point for resolving time differences when running Debian 12 in a dual boot setup.

Comment below if this fix worked for you!!

Resolving Display and WiFi Issues on Debian 12(DELL 5550, Display driver and Intel wireless firmware)


Recently I installed Debian 12 bookworm for a change, I encountered a couple of frustrating issues with my system's display driver and Intel wireless WiFi adapter. My DELL laptop had the latest Intel Arc Graphics, but the live Debian version installed kernel version 6.1, which did not have the drivers.

naveenr@latitude5550:~$ lspci -k | grep -EA3 'VGA'
00:02.0 VGA compatible controller: Intel Corporation Meteor Lake-P [Intel Arc Graphics] (rev 08)
Subsystem: Dell Meteor Lake-P [Intel Arc Graphics]
Kernel driver in use: i915
Kernel modules: i915, xe

Symptoms:

  • Very few display resolutions supported
  • Display brightness not working
  • Laptop special keys not working(like brightness increase and decrease )
  • Bluetooth not working
  • WiFi not working.
Fortunately, I was able to find a solution that got everything working properly.

Display Driver Problems

The recommended solution was to upgrade the Linux kernel and firmware packages to the versions available in the Debian "bookworm-backports" repository. To do this, I ran the following commands:

sudo apt -t bookworm-backports install linux-image-amd64

This updated my kernel to the latest version and all display issues got resolved(after debian reboot).

Resolving the WiFi Issue

In addition to the display problems, I was also having trouble connecting to my wireless network. My Intel WiFi adapter was not being recognized properly, and I couldn't get an internet connection. Again, I turned to the Debian forums and found that this was a common issue with Debian 12 and Intel wireless adapters. The solution was to install the firmware-iwlwifi package from the "bookworm-backports" repository, which I did using the command above.

sudo apt install firmware-iwlwifi/bookworm-backports



After running these commands, my display issues were resolved, and my wireless adapter started working correctly(after debian reboot). I was able to get back to using my Debian 12 system without any further problems.

Comment if you found this blog helpful.

Wednesday, April 30, 2025

How to Disable Auto Word Select in Office 365 Outlook

 

Introduction

Auto word select is a feature in Office 365 Outlook that automatically selects entire words when you click on them. While this can be helpful for some users, it can be quite annoying for others who prefer more precise control over text selection. Fortunately, disabling this feature is straightforward. In this blog post, we'll walk you through the steps to turn off auto word select in Office 365 Outlook.

Steps to Disable Auto Word Select

  1. Open Outlook: Start by opening your Office 365 Outlook application.

  2. Access Options:

    • Click on the File tab located at the top left corner of the window.
    • Select Options from the menu. This will open the Outlook Options dialog box.
  3. Navigate to Mail Settings:

    • In the Outlook Options dialog box, click on Mail in the left-hand sidebar.
  4. Editor Options:

    • Under the Mail settings, find and click on Editor Options. This will open another dialog box with various settings related to composing and editing emails.
  5. Advanced Settings:

    • In the Editor Options dialog box, click on the Advanced tab.
  6. Disable Auto Word Select:

    • Scroll down to the Editing options section.
    • Look for the option labeled When selecting, automatically select entire word.
    • Uncheck this box to disable the auto word select feature.
  7. Save Changes:

    • Click OK to save your changes and close the Editor Options dialog box.
    • Click OK again to close the Outlook Options dialog box.

Sunday, April 13, 2025

Downloading All Your Google Account Data in One Shot

Introduction

In today's digital age, it's essential to have control over your online presence and personal data. If you're concerned about your Google account security or want to transfer your data to another platform, downloading all your data at once is a great way to go. In this blog, we'll walk you through the process of downloading all your Google account data in one shot.

Preparation

Before you start, make sure you have:

1. A reliable internet connection

2. A Google account with access to all the data you want to download (e.g., Gmail, Google Drive, Google Photos)

3. The necessary permissions to download and transfer data

Step 1: Enable the Download Option

To download your Google account data, follow these steps:

1. Go to the Google Account settings page (https://myaccount.google.com)

2. Click on "Data & personalization"

3. Scroll down to the "Download your data" section

4. Click on the "Next" button

Step 2: Choose Your Data Sources

You'll be asked to select which data sources you want to download:

1. Gmail emails and attachments

2. Google Drive files

3. Google Photos (optional)

4. Google Account information (e.g., contacts, calendar)

Choose all the options that apply to you.

Step 3: Download Your Data

Click on the "Create archive" button to start the download process:

1. The Google account system will create a compressed archive file containing your data

2. This may take several minutes or hours, depending on the amount of data being downloaded

Where to Find Your Downloaded Archive

After the download is complete, you'll receive an email with instructions on where to find your archived data:

1. Check your email for a message from Google with the subject "Your data has been uploaded"

2. Click on the link provided to access your downloaded archive

What's in the Archive?

The archived file will include:

* Gmail emails and attachments

* Google Drive files

* Google Photos (if you chose this option)

* Google Account information (e.g., contacts, calendar)

You can extract individual files or restore your entire archive to a new Google account.

Tips and Considerations

Before downloading all your data, consider the following:

1. Data size: Large archives may take time to download and store.

2. Storage space: You'll need sufficient storage space on your device or cloud storage services to accommodate the archived file.

3. Security: Be cautious when transferring sensitive information; ensure you're using a secure connection (HTTPS) and a trusted device.

4. Backup: Consider creating regular backups of your data to prevent loss in case something goes wrong.

References


Monday, March 17, 2025

How to Use the patch Command in Linux

 The patch command in Linux is a powerful tool used to apply changes to files based on differences (diffs) between file versions. It's commonly used in software development to update source code files. In this blog post, we'll explore how to use the patch command with practical examples.

Understanding the patch Command

The patch command takes a patch file (which contains differences between files) and applies those changes to the original file. The patch file is usually created using the diff command.

Basic Syntax

patch [options] [originalfile] [patchfile]
  • originalfile: The file to be patched.
  • patchfile: The file containing the differences.

Creating a Patch File

Before we can use the patch command, we need a patch file. Let's create one using the diff command.

Example: Creating a Patch File

Suppose we have two files, file1.txt and file2.txt, and we want to create a patch file that contains the differences between them.

diff -u file1.txt file2.txt > changes.patch

This command generates a unified diff and saves it to changes.patch.

Applying a Patch

Now that we have our patch file, let's apply it using the patch command.

Example: Applying a Patch

patch file1.txt < changes.patch

This command applies the changes from changes.patch to file1.txt.

Common Options

The patch command has several options that can be useful:

  • -pNUM: Strip NUM leading components from file names.
  • -R: Reverse the patch (undo changes).
  • --dry-run: Test the patch without applying changes.

Example: Using Options

patch -p1 file1.txt < changes.patch

This command strips one leading component from file names before applying the patch.

Handling Rejected Patches

Sometimes, patches may not apply cleanly, resulting in rejected patches. These are saved in .rej files.

Example: Handling Rejected Patches

patch file1.txt < changes.patch

If there are rejected patches, they will be saved in file1.txt.rej. You can manually review and apply these changes.

Thursday, March 6, 2025

Information about National Pension System



Understanding the National Pension System (NPS) in India

The National Pension System (NPS) is a government-sponsored pension scheme launched in January 2004. It was initially introduced for government employees but was later extended to all Indian citizens in 2009. The NPS aims to provide a sustainable solution for retirement planning by encouraging individuals to save systematically during their working years.

Key Features of NPS

  1. Voluntary Participation: NPS is open to all Indian citizens aged between 18 and 65. Participation is voluntary, allowing individuals to join and contribute according to their financial capacity.

  2. Flexible Contributions: Subscribers can decide how much they want to contribute and when. There is no fixed amount or frequency, making it a flexible option for retirement savings.

  3. Tax Benefits: Contributions to NPS are eligible for tax deductions under Section 80C and Section 80CCD of the Income Tax Act. This makes NPS an attractive option for tax planning.

  4. Investment Options: NPS offers a variety of investment options, including equity, corporate bonds, and government securities. Subscribers can choose their preferred investment mix based on their risk appetite.

  5. Professional Management: The funds in NPS are managed by professional pension fund managers appointed by the Pension Fund Regulatory and Development Authority (PFRDA). This ensures that the investments are handled efficiently and transparently.

  6. Portability: NPS accounts are portable across jobs and locations. This means that subscribers can continue their contributions even if they change jobs or move to a different city.

How NPS Works

When you join NPS, you open an individual pension account known as a Permanent Retirement Account Number (PRAN). There are two types of accounts under NPS:
  1. Tier I Account: This is the primary pension account with restrictions on withdrawals. It is mandatory to open a Tier I account to join NPS. Contributions to this account are eligible for tax benefits.

  2. Tier II Account: This is a voluntary savings account with no withdrawal restrictions. However, contributions to the Tier II account do not qualify for tax benefits.

Withdrawal and Annuity

Upon reaching the age of 60, subscribers can withdraw up to 60% of the accumulated corpus as a lump sum. The remaining 40% must be used to purchase an annuity, which provides a regular pension income. In case of early exit before the age of 60, 80% of the corpus must be used to purchase an annuity, and the remaining 20% can be withdrawn as a lump sum.

 

For more information see youtube video by LLA advisor:  https://www.youtube.com/watch?v=jSF9kdYjiYY

Thursday, February 27, 2025

Troubleshooting Disk Quota Exceeded Error While Installing Triton from Source

 If you've encountered the [Errno 122] Disk quota exceeded error while installing the Triton Python package from source, you're not alone. This error typically indicates that your home directory has run out of disk space. In this post, we'll walk through the root cause of this issue and how to resolve it.

Understanding the Error

The error message [Errno 122] Disk quota exceeded is a clear indication that the disk space allocated to your home directory is insufficient. This can happen during the installation process of Triton, especially when it tries to extract LLVM into the ~/.triton directory.

Root Cause

The Triton build process uses the ~/.triton directory to extract LLVM, which can consume a significant amount of disk space. If your home directory has limited space, this can lead to the disk quota being exceeded.

Steps to Resolve

  1. Check Disk Usage: First, check the current disk usage of your home directory to confirm that it is indeed full.

    du -sh ~
    
  2. Free Up Space: If your home directory is full, you can free up space by deleting unnecessary files or moving them to another location.

    rm -rf ~/unnecessary-file-or-directory
    
    #Another way is you can create symlink to tmp if you homedirectory does not have enough diskspace
    mkdir /tmp/triton_tmp
    ln -s /tmp/triton_tmp ~/.triton
  3. Change Extraction Directory: You can change the directory where Triton extracts LLVM to a location with more available space. Set the TRITON_CACHE_DIR environment variable to a directory with sufficient space.

    export TRITON_CACHE_DIR=/path/to/large/directory
    
  4. Re-run Installation: After freeing up space or changing the extraction directory, try running the installation process again.

    pip install -e .
    
    # URL: https://github.com/triton-lang/triton/blob/main/docs/getting-started/installation.rst

Thursday, February 20, 2025

Bash emacs Readline Reference Guide

 

Enabling emacs Mode

To enable emacs mode in Bash, add the following line to your .bashrc file:

set -o emacs

Then, reload your .bashrc file:

source ~/.bashrc

Basic Navigation

  • Ctrl-a: Move to the beginning of the line.
  • Ctrl-e: Move to the end of the line.
  • Ctrl-b: Move backward one character.
  • Ctrl-f: Move forward one character.
  • Meta-b: Move backward one word.
  • Meta-f: Move forward one word.

Editing

  • Ctrl-d: Delete the character under the cursor.
  • Ctrl-k: Delete from the cursor to the end of the line.
  • Ctrl-u: Delete from the cursor to the beginning of the line.
  • Ctrl-w: Delete the word before the cursor.
  • Meta-d: Delete the word after the cursor.
  • Ctrl-y: Yank (paste) the last killed text.
  • Ctrl-_ or Ctrl-x Ctrl-u: Undo the last change.

Inserting Text

  • Ctrl-t: Transpose the character before the cursor with the character under the cursor.
  • Meta-t: Transpose the word before the cursor with the word under the cursor.

Searching

  • Ctrl-r: Search backward incrementally.
  • Ctrl-s: Search forward incrementally.

Miscellaneous

  • Ctrl-l: Clear the screen and redisplay the current line at the top.
  • Ctrl-x Ctrl-e: Open the current command in the default editor (usually emacs).

Key Modifiers

  • Ctrl (Control): Often abbreviated as C-.
  • Meta (usually Alt or Esc): Often abbreviated as M-.

Bash vi Readline Reference Guide

 

Enabling vi Mode

To enable vi mode in Bash, add the following line to your .bashrc file:

set -o vi

Then, reload your .bashrc file:

source ~/.bashrc

Basic Modes

  • Command Mode: This is the default mode. You can navigate and edit the command line.
  • Insert Mode: Enter this mode to insert text. Press i to switch to Insert mode from Command mode.

Navigation

  • hjkl: Move left, down, up, and right respectively.
  • 0: Move to the beginning of the line.
  • $: Move to the end of the line.
  • w: Move to the beginning of the next word.
  • b: Move to the beginning of the previous word.

Editing

  • x: Delete the character under the cursor.
  • dw: Delete from the cursor to the end of the word.
  • dd: Delete the entire line.
  • u: Undo the last change.
  • Ctrl-r: Redo the last undone change.

Inserting Text

  • i: Insert text before the cursor.
  • a: Insert text after the cursor.
  • I: Insert text at the beginning of the line.
  • A: Insert text at the end of the line.
  • o: Open a new line below the current line and enter Insert mode.

Searching

  • /pattern: Search forward for pattern.
  • ?pattern: Search backward for pattern.
  • n: Repeat the last search in the same direction.
  • N: Repeat the last search in the opposite direction.

Miscellaneous

  • .: Repeat the last command.
  • Ctrl-[: Exit Insert mode and return to Command mode.
  • v: Open the current command in the vi editor.

Tuesday, February 4, 2025

Mastering tput Commands for Color Printing and Terminal Control

 `tput` is a command-line utility in Linux systems that allows you to control terminal settings, such as changing colors or setting font attributes. It provides a range of options for customizing your output and enhancing the user experience.

In this guide, we'll explore the various features of `tput`, including color printing, font styles, cursor positioning, and more. Whether you're a developer looking to create visually

appealing command-line interfaces (CLI) or a system administrator seeking to improve terminal usability, this article will equip you with the knowledge necessary to harness the full potential of `tput`.

Color Printing with tput

To print colored output using `tput`, you need to specify color codes in the format recommended by the terminal being used. Most terminals support ANSI escape sequences, which allow for text formatting and changing colors among other things.

Color Codes

*   Foreground colors: 30-37 (red through white), 90-97 (bright red through bright white)

*   Background colors: 40-47 (red through white), 100-107 (bright red through bright white)

Example Code for Color Printing

tput setaf 1 # red
echo "Hello"

tput setab 4 # blue background
echo "World"

Resetting Colors with tput

To reset the colors after printing, use `tput sgr0` or `tput reset`. This command resets all attributes back to default (color, font style, etc.).

Example Code for Resetting Colors

tput setaf 1; echo "Hello"; tput sgr0 # resets color after printing

Additional Features of tput


In addition to color printing and resetting colors, `tput` offers various other features that can be used to enhance the user experience.

Setting Bold Text


`tput bold`: Makes text appear in a bold font.


tput bold; echo "Bold text"; tput sgr0 # sets text to bold and resets later


Setting Italic Text (Supported by Some Terminals)


`tput sitm` or `tput rmso`: Not all terminals support italic formatting, so use with caution. To reset the font style back to normal, use `tput rmso`.


Setting Underline Text (Supported by Some Terminals)

`tput smul` or `tput rmul`: Not all terminals support underlining, so use with caution. To reset the font style back to normal, use `tput rmul`.

Clearing Screen


`tput clear`: Clears the entire screen of any output.

tput clear
echo "New content here"


Cursor Control with tput


`tput civis` or `tput cvvis`: Hides or shows the cursor from view.

tput civis; echo "Hidden"; tput cvvis # hides and shows the cursor

Monday, February 3, 2025

ANSI escape sequences to print colored text(linux terminal)


ANSI escape sequences are a standardized way to add color and formatting to text in the terminal. Here are some common ANSI escape sequences for printing colored text:

Color Codes(Foreground)

Color

Code

Reset

\033[0m

Black

\033[30m

Red

\033[31m

Green

\033[32m

Yellow

\033[33m

Blue

\033[34m

Magenta

\033[35m

Cyan

\033[36m

White

\033[37m

Background Color Codes

Color

Code

Black Background

\033[40m

Red Background

\033[41m

Green Background

\033[42m

Yellow Background

\033[43m

Blue Background

\033[44m

Magenta Background

\033[45m

Cyan Background

\033[46m

White Background

\033[47m



Example Usage in Python

print("\033[31m" + "This text is red" + "\033[0m")

print("\033[32m" + "This text is green" + "\033[0m")

print("\033[34m" + "This text is blue" + "\033[0m")

print("\033[41m" + "This text has a red background" + "\033[0m")

print("\033[42m" + "This text has a green background" + "\033[0m")

Note

  • ANSI escape sequences may not work on all systems or terminals.
  • The \033[ code is the ESCAPE sequence that starts the ANSI command.
  • The m at the end of each code is what actually applies the change.

Other useful escape sequences:

To clear the whole line in a bash script when using \r to print on the same line, you can use the following methods:

Method 1: Using ANSI Escape Sequences

Bash

echo -ne "\r\033[K"

  • \r moves the cursor to the beginning of the line.
  • \033[K clears the line from the cursor position to the end.
Using printf command:

printf "\r%s \x1b[32m%s\x1b[0m\033[K\n" "$test_name" "Passed."

Method 2: Using tput

Bash

echo -ne "\r$(tput el)"

  • \r moves the cursor to the beginning of the line.
  • tput el clears the line from the cursor position to the end.

Example Usage

Bash

for i in {1..10}; do
    echo -ne "\rProgress: $i%"
    sleep 0.5
done
echo -ne "\r\033[K"
echo "Done!"

In this example, the progress is printed on the same line, and after the loop finishes, the line is cleared, and "Done!" is printed.

 

 

Why the name BFD linker?

 The Linux linker got its name "BFD Linker" because of a fascinating piece of history.

What's BFD?

BFD stands for Binary File Descriptor. It's a library and set of tools created in 1996 by Adam Beneschan, originally at Red Hat. The primary goal was to provide a unified interface for working with various file formats, including binary executables, object files, libraries, and archives.

Why the BFD linker?

The first implementation of the Linux linker (link editor) was called `ld` (short for link editor). In 1997, David S. Miller, a key figure in the development of the Linux kernel, started working on a new version of the linker that would utilize the BFD library.

This new version, also named `ld`, used BFD as its backend to manage and manipulate binary files. As a result, the linker became known as the BFD Linker or BFD ld, in honor of its BFD foundation.

Why is it the default linker?

Today, the BFD linker (or simply `ld`) remains the default linker on Linux because:

1. Maturity and stability: The BFD linker has been around for a long time (over 25 years now) and has been extensively tested and refined.

2. Feature set: It supports an impressive range of formats, including ELF (Executable and Linkable Format), a.out, COFF, and more.

3. Portability: The BFD linker is designed to be highly portable across various architectures, making it an ideal choice for Linux's diverse hardware ecosystem.

4. Industry adoption: As the default linker on many Linux distributions, including Red Hat Enterprise Linux (RHEL), CentOS, and Fedora, the BFD linker has become a de facto standard.

Other linkers

While `ld` (BFD Linker) is the default linker on most Linux systems, there are other linkers available for specific use cases or architectures:

* gold: A fast and modular linker developed by Red Hat.

* lld: The LLVM Linker, which offers a different approach to linking using the LLVM infrastructure.

These alternatives often coexist alongside `ld` (BFD Linker) in Linux distributions.

Sunday, February 2, 2025

Using ImageMagick AppImage on Windows with WSL

As a developer, you might have encountered situations where you need to manipulate images programmatically. ImageMagick is a powerful command-line tool that provides a wide range of image processing capabilities. However, installing it on Windows can be a bit tricky due to compatibility issues and dependencies. In this blog post, we'll explore how to use ImageMagick AppImage on Windows with WSL (Windows Subsystem for Linux).

What is AppImage?

AppImage is a format that packages an application in a single file, making it easy to distribute and run on various platforms. It's essentially a self-contained bundle of the application, libraries, and dependencies.

Prerequisites

To follow along with this tutorial, you'll need:

1. Windows 10 (or later)

2. WSL (available in Windows 10 Fall Creators Update or later)

3. ImageMagick AppImage file (download from https://www.imagemagick.org/script/download.php)

Step-by-Step Installation and Usage


Step 1: Enable WSL

If you haven't already, enable the WSL feature in Windows:

* Go to `Settings` > `Apps & features`

* Click on `Programs and Features`

* Check the box next to `Windows Subsystem for Linux`


Step 2: Install AppImage Launcher (optional)

While not required, installing the AppImage launcher can make it easier to run your AppImages:

1. Open a new WSL terminal

2. Run `sudo apt-get update && sudo apt-get install appimage-runner`

3. Close the WSL terminal

Step 3: Download and Launch ImageMagick AppImage

Download the ImageMagick AppImage file from https://www.imagemagick.org/script/download.php.

1. Move the downloaded AppImage file to a convenient location, such as your desktop.

2. Open a new WSL terminal

3. Navigate to the directory where you saved the AppImage file (e.g., `cd ~/Desktop`)

4. Run `./Magick-Studio-Q16HD-Q8-x86_64.appimage` (replace with the actual filename and path)

This will launch the ImageMagick application inside WSL.

Step 4: Basic Usage

To verify that ImageMagick is working, try some basic operations:

1. Create a new image:

        * `magic convert -size 800x600 xc:white output.png`

        * This will create an image called `output.png` in the current directory

2. Display an existing image:

        * `magic display input.jpg`

        * This will display the `input.jpg` file using your default image viewer

3. Resize an image:

        * `magic convert input.jpg -resize 50% output-resized.jpg`

These commands demonstrate some basic usage of ImageMagick inside WSL.

Reference links: https://usage.imagemagick.org/basics

Saturday, February 1, 2025

Efficient Photo Compression with ImageMagick AppImage on Ubuntu

 

As a photographer who frequently deals with large batches of high-resolution photos, I've found ImageMagick's AppImage to be an invaluable tool for image compression. Today, I'll show you how to use this powerful utility to compress JPEG files without installing anything system-wide.

Why AppImage?

AppImage is a format for distributing portable software on Linux. Unlike traditional installation methods, AppImage provides a single, self-contained executable that includes all dependencies. This makes ImageMagick incredibly easy to use - just download and run!

Getting Started

  1. First, download the ImageMagick AppImage from the official release page.
    https://imagemagick.org/script/download.php
  2. Make it executable:
    chmod +x ~/Downloads/magick

The Magic Command

Here's the bash script I use for batch compression:

[BASH]
for f in *.JPG ; do echo "compressing $f..." ~/Downloads/magick "$f" -quality 60 "../../magick_output/$f-comp".JPG done

Let's break down what this command does:

  • for f in *.JPG - Loops through all files ending in .JPG in the current directory
  • echo "compressing $f..." - Provides feedback about which file is being processed
  • ~/Downloads/magick - Path to our ImageMagick AppImage
  • -quality 60 - Sets JPEG quality to 60% (adjust this value based on your needs)
  • "../../magick_output/$f-comp".JPG - Saves the compressed file in a separate directory with "-comp" suffix

Choosing the Right Quality Setting

The -quality parameter accepts values from 1 to 100:

  • 100: Maximum quality, minimal compression
  • 80-90: High quality, good compression
  • 60-70: Balanced quality/size ratio
  • Below 50: Noticeable quality loss, maximum compression

I've found that 60 provides an excellent balance between file size reduction and visual quality for most photographs. However, you might want to adjust this based on your specific needs.

Pro Tips

  1. Create Output Directory First: Make sure your output directory exists before running the command:
    mkdir -p ../../magick_output
  2. Preview Before Batch Processing: Test your settings on a single image first:
    ~/Downloads/magick test.JPG -quality 60 test-compressed.JPG
  3. Check File Sizes: Use ls -lh to compare original and compressed file sizes:
    ls -lh original.JPG compressed.JPG

Resource Usage

One of the benefits of using ImageMagick's AppImage is its efficient resource usage. Unlike web-based compression tools, it processes files locally and quickly. On my system, it typically processes a 20MB JPEG file in under a second.


Final thoughts: Remember to always keep backups of your original files before performing batch operations. Happy compressing!