Batch resising for web

Sun 05 October 2025
Smaller environment (Photo credit: wikipedia)

I recently tried to measure the environmental impact of this website. I used an online tool. The result shows the easiest way to improve my score was to reduce image sizes. This could easily be done with ImageMagick.

I wrote a small bach script to resize my files:

#!/bin/bash

# resize images for web use

target_size=200 # in kb
output_dir="web"
mkdir -p $output_dir

resize_image() {
    echo "image $1..."
    output_file=$output_dir/$1
    cp "$1" "$output_file"
    current_size=$(( $(stat -c%s "$output_file") / 1024 ))
    factor=95
    while (( current_size > target_size ))
    do
        echo "current size: $current_size"
        current_size=$(( $(stat -c%s "$output_file") / 1024 ))
        magick "$1" -resize $factor% "$output_file"
        factor=$(( factor - 5 ))
    done
}

for image in *jpg
do
    resize_image "$image"
done

It tries several resize factor (while loop, factor being redefined line 20) until the output size is lower than a predefined threshold.

Then, I needed to replace path in all my articles.

Category: how to Tagged: bash jpg magick web blog how to


Travis setup

Tue 12 May 2020
One job in continuous integration pipeline (Photo credit: Wikipedia)

The goal is to setup a CI pipeline based on Travis with external dependencies integrated to a Github repository

Travis basics

To enable Travis integration in Github, one must edit ./.travis.yml file.

I won't go into detail. The setup is …

Category: how to Tagged: travis ci how to

Read More

LaTeX makefile updated

Fri 29 March 2019

My default LaTeX makefile evolved. Here is an update:

The makefile looks like:

LATEX=pdflatex
BIBTEX=bibtex
BIB=
RERUN='(There is undefined reference|Rerun to get (cross-references|the bars) right)'

%.pdf:%.tex
    ${LATEX} $<
    @if [ -e $*.bbl ]; then ${BIBTEX} $* && ${LATEX} $< && ${LATEX} $< ; fi
    @if egrep -q $(RERUN) $*.log ; then ${LATEX} $< ; fi

%.aux …

Category: tools Tagged: GNU LaTeX Makefile Writing how to tools

Read More

Functional Block diagram

Thu 28 March 2019

How to make a block diagram with \(\text{\LaTeX}\)?

This article is mainly inspired by tex example.

Here is an example with tikz resulting in the following figure:

The code:

\documentclass{article}
\usepackage[landscape,margin=1cm]{geometry}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}


\tikzstyle{block}=[draw,fill=red …

Category: LaTeX Tagged: LaTeX how to

Read More

Conference posters

Fri 11 December 2015
English: This mindmap (Mind map) consists of r...

mindmap needing clarification (Photo credit: Wikipedia)

Few weeks ago, I wrote about mindmap in LaTeX . Now I want to precise few ideas and to have all key ideas visible in one sight. I think the best layout is similar to a conference poster:

  • key ideas are easily seen few meters away …

Category: LaTeX Tagged: LaTeX Poster how to tools

Read More
Page 1 of 2

Next »