Slice up an image in equal slices with ImageMagick or a progress bar in 100 images

Let's assume we need a progress bar in 101 images where each shows a particular percentage form 0 to 100. How to create such image will be explained in the next post (not ready yet at the time of writing). I already prepared the image here.

The easiest way to slice up an image is in a command line using ImageMagick's a crop flag. The first command shows the image file we are going to slice. The second command (which should be in one line) is a simple a bash for loop and in each iteration we create a new slice. The third command just lists files that we created.

 mk@here/$ ls

 mk@here/$ for((i=0; i<101; i++)) ; do n=$[i*22]; \ 
           convert progressbar_small.png -crop 500x22+0+$n +repage progressbar${i}.png; \

 mk@here/$ ls
 progressbar0.png    progressbar32.png  progressbar56.png  progressbar7.png
 progressbar2.png    progressbar53.png  progressbar77.png  progressbar_small.png

The -crop flag slices up images 500px wide and 22px high and starts at 0px on the X axis and goes down 22*i where i runs from 0 to 100. The end results are 100 images.

All images are available in this zip file.

LaTeX - insert a PDF table as an image in a table environment

On of the most painful (at least IMHO) things to create in LaTeX are complex or big tables. It is easier to make them in a spreadsheet software (Libreoffice Calc, MS Excel or even Word) and export them as PDFs (either File->Export as PDF, File->Save as or using PDFCreator). It is possible to insert PDFs as images in figure environment like this:

 \caption{Similarities and overlap between the two PIM frameworks}

However, this caption starts with the word "Image X: ..." while I want to have a caption stating with "Table X: ...".

It is possible to insert a PDF in a table environment as well like this:

  \caption{A table}

If a PDF needs to be cropped you can do it like this:

                                                       %left, bottom, right, top
\includegraphics[width=0.85\textwidth, clip=true, trim=0cm 0cm 0cm 0cm]

You might also need the following package:


Add a blur to a part of a video with Avidemux

I made a video of how to emphasize (add a circle over a face) things in a video with Avidemux. The same can be done for adding a blur with a different filter - Mplayer delogo.

However, blurring just one part of the video with the Mplayer delogo filter once failed on me. I wanted to add a blur just for five seconds over a face in a longer video. If I didn't specify the frames (Partial button in step 5 of the previous tutorial) I got the blur over the whole length of the video. With Partial selected I ended up with a destroyed video.

Let say I want to add a blur from the frame 500 to the frame 600 on a video of 1000 frames.

1. Split the video in 3 parts
Use the reddish buttons A & B at the bottom of the video to select UNDESIRED parts of it and use Edit->Delete to cut bits of the video out. Save each part as it's own file (no encoding needed so both video and audio remain on Copy) so we end up with 3 files:  first from frame 0-499, second from frame 500-600 and third from frame 601-100.

2. Add a blur to the second video file
Use the procedure of the previous tutorial but select Mplayer delogo as a filter (and don't forget to encode the video).

3. Concatenate the three videos.
Open the first one and select File->Append to add the other two in the right order

Here's the video (sorry I forgot to turn the mic on but it's short and self explanatory).

Add circle, logo, image or blur to video with Avidemux

I needed to add a red circle on a video to emphasize the content over a period of a few seconds. It turns out that this is fairly simple with Avidemux.

1. Create a PNG image of a circle with a transparent background (I did it in Gimp and its beyond this tutorial)
2. Open a video file in avidemux.
3. From the menu select Video -> Filter to open Video Filter Manager, then select Miscellaneous on the left and doubleclick on Logo (add a png as logo) on the right.
4. In new window select a logo file, enter X and Y positions in pixels from the top left corner, choose transparency (0 means fully transparent and 255 not) and click OK button.
5. Back on Video Filter Manager click on Partial button on the bottom of the window, in a new window enter the frames (which can be found out on the main video window) and click OK button.
6. Click on the Close button on the Video Filter Manager to return to the main video window and left to the video select the encoding type instead of default Copy.
7. Just re-save the video.

A logo can be added the same way, just don't use a partial filter (step 5) and alpha should be 255 (no transparency in step 4).

To blur a certain part of a video (square shaped), just use another filter instead (step 3): Mplayer delogo, enter the position and size of the blurred square/rectangle area.

To move an image (circle) together with the video (for example to follow the face of a person) use several Logo filters and adjust X and Y accordingly to each of them.

Taps 13: confusing pulling and turning

This one was tricky even for me, not to mention my son who tried to rotate the left knob (the right one is for soap) for at least a minute before he started to complain. The tap has usual two features:

  • Controlling the flow: by pulling out the little stick on the knob out
  • Controlling the temperature: by turning the knob left and right

Also not clear is on which side the temperature is cold and on which hot.