Skip to main content

Posts

Replace transparency in PNG images with white background (for lots of files...)

I had to remove transparency from a PNG image file from the command line... and stack overflow came into my help[1]... But I needed it for lots of files... then, adding a "while read line" did the job: ls -1 *.png |  cut -d . -f 1 | while read line; do convert -flatten $line.png flatten/$line.png ; done; [1] Replace transparency in PNG images with white background https://stackoverflow.com/questions/2322750/replace-transparency-in-png-images-with-white-background
Recent posts

Tuftefying jQuery Flot

It has been a while since my last post (almost 2 years), even longer since my post on Tufte-style-ish plots... ( On Tuftefying gnuplot ). As I am now more on  FlotJs  ... I was looking around for the same "Tuftefying" style tutorial, but this time using FlotJs as an example... And right in the first googling, it came out: " Tufte Bar Chart Redesign in jQuery Flot "

Arduino map function decimal places (floating point numbers)

The programming library available with the Arduino has an interesting interpolation function, the  map  function. Sadly, it returns only integers. As you might want to interpolate floating point numbers for some instrumentation routines, this limitation with integers may lend you to some low-resolution results. Fortunately, Arduino supports method overloading, and we can rewrite another  map  function to support floating point numbers. The new  map  function could be like this: float map(int x, double in_min, double in_max, double out_min, double out_max){  return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min; }

How much space emacs backup files are using...?

Every time I use emacs, it automatically saves a backup file which filename ends with "~". From time to time, I issue a recursive find command to wipe out  (delete) every emacs backup file from my home folder. find . -iname \*~ -exec rm -rfv {} \; And everything is clean. I do it strictly to clean things up... not for any disk space concern...  But I was wondering how much disk space those backup files are consuming... So, instead of an rm command, I had executed a df and piped all to awk to summarize... find . -iname \*~  -exec du -s {} \; | cut -f 1 | awk '{s+=$1} END {print s}' This time all the emacs backup files were consuming only 1.6M, which isn't big deal... but I think it is better to get rid of them.

Extracting embedded images from SVG

With Inkscape, one can open and edit PDF files. But when the PDF comes with embedded images, the resulting SVG keeps the images as an embedded base64 encoded data. I wanted to extract those embedded images from the resulting SVG. But I didn't want to use the "export bitmap" option on Inkscape to extract those images, as within this way I wouldn't really know the original resolution besides the fact that Inkscape would re-encode the image data. So I wrote this one line to extract all images from one SVG. i=1; grep data:image test.svg  | cut -d "," -f 2 | cut -d \" -f 1 |while read line ; do echo $line | base64 --decode >  $i.png ; i=$((i+1)); done 

Now, the kid's time

After my little experiment wit clay stop motion animation (link), I brought the camera home and showed the process to my kids... My older son wanted to give it a try... And here is his first movie.

Clay stop motion

A colleague from just the neighbor lab found an old webcam, which has no support (driver) for his Windows 7... He asked me to try to find a Windows 7 driver or some driver which make the cam work for him... As I use a Linux workstation, I've just plugged the camera into an USB port to see what do I get. The camera worked pretty nicely...So we've launched "Cheese" and grab some pictures of some clay that was laying around... It took less than 5 minutes to make this small animation... https://youtu.be/KD4sKULZF_U After that, he forgot the windows driver and he lent that camera to me to play with the kids.