Applications


Ubuntu Linux: How to Resize and add Label to a many picture files 1

Lets say you have a ton of pictures or photos that you want to resize and add a semi-transparent label at the bottom of this bulk of files and even rename them using a pattern based on a unique number.

You can either do this manually or by using imagemagick. If you chose the second way follow these steps:

First of all install it, from bash/terminal call the following:

sudo apt-get install imagemagick

When that command is successfully completed, navigate to the location that the pictures are and once you are there:

In order to resize all pictures then issue the following command (in this example we make all pictures at most 1200px long or 1200px tall and keep the aspect ratio) :

mogrify -resize 1200 *

NOTE: It will affect the original files! So if you want to keep them make sure to copy them elsewhere BEFORE issuing the above command.

After the above is done, you can issue the following set of commands to:

  1. Get each file and find it’s dimensions (which later will be used for the label creation)
  2. Rename all pictures following the number based pattern
  3. Add a semitransparent label containing custom text at the bottom
counter=0; for i in *;
do let counter=counter+1;
width=`identify -format %w "$i"`;
convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg;
done

This command will preserve the original files.
All together with printing the file that is being processed as debuging information:

mogrify -resize 1200 *; counter=0; for i in *; do let counter=counter+1; echo $i; width=`identify -format %w "$i"`; convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg; done

Sample/Result Photos:

 


Beta test dropbox and get even more free space!

We tried this and it works!

Dropbox is now offering a way of increasing your free space by trying out an Experimental build of the application that allows your machine to scan an external device, like a cell phone mounted as a hard disk, and automatically sync the contents of the folder with your dropbox account.

What they promised is that for every 500MB of uploaded material through the autorun feature on the device uploaded to your profile, you will get it back for free with a limit of going up to 5GB, which is not something to joke about especially for the folks that have 2GB or 2.25GB only. (Tip: you get the first 500MB by just uploading a single photograph :))

How to get and use this build:

  1.  Go to this site http://forums.dropbox.com/forum-build.php which will guide you to the page the build information
  2. Download one of the distributions, depending on your system. (The day this article was written this was the latest build for Windows:
    > Windows: http://dl-web.dropbox.com/u/17/Dropbox%201.3.14.exe
  3. Of course install it as usual, and when you are done make sure it is running
  4. After that, mount your mobile device as an external disk drive to your computer and wait for the autorun menu to appear (if it doesn’t go to ‘My Computer’, right click on the device and select autorun)
  5. From the new window select the dropbox functionality as follows and give it some time to do its magic 🙂

Note: All uploaded photos will be renamed to this format  “<Year>-<Month>-<Day> <Hour>.<Minute>.<Second?>-<Increasing Number if needed>”(e.g 2012-02-07 15.12.22.jpg) but they will not lose their EXIF information.

Note: You will be able to find your uploaded photographs in the folder ‘Camera Uploads’ in the main folder of your dropbox account.

Sources:
(2/1) – Experimental Forum Build – 1.3.12
(2/7) – Experimental Forum Build – 1.3.14
These threads could become obsolete any day now so be sure to check out this page (newer forum build), which we believe will keep on taking you to the latest information.


Ubuntu 11.10 (Oneiric Ocelot): Cloning a KVM Virtual Machine

After properly installing and creating your first virtual machine, you might want to create a clone for some reason.

To do this we use the command virt-clone as follows:

sudo virt-clone --connect qemu:///system -o coeus -n phoebe -f /home/kvm/2KA.qcow2 -f /home/kvm/zK6.qcow2 --force

Where:

  • –connect is used to connect to the hypervisor of the virtual machine, here it is system
  • -o is the original virtual machine name (which is registered with the previous hypervisor)
  • -n is the name of the new virtual machine, the clone (this name will be used to register the clone to the hypervisor)
  • -f the location that the clone will use to store it’s virtual hard drives, can be used as many times as needed (in the above example coeus has two hard disks and that is why we need to provide two -f paramaters)
  • –force prevents interactive prompts and replies ‘yes’ to all yes/no questions

There is more directives that can be provided to the clone manager from which a very important one is the: –mac where you get to define the mac address of the new virtual machine (e.g –mac C0:FF:EE:11:00:11)


KVM: How to configure a bridge connection in Ubuntu 11.10 2

Make the file : /etc/network/interfaces  look something like this (make changes only to br0, add it if not there and to the device that you want to bridge with, we used eth1):

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp

# Building a bridge to be used by the Virtual Machines
auto br0
iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth1
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

Then issue: sudo /etc/init.d/networking restart
If you get:

* Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
 * Reconfiguring network interfaces...                                                                                                                                                    RTNETLINK answers: File exists
ssh stop/waiting
ssh start/running, process 11489

Waiting for br0 to get ready (MAXWAIT is 20 seconds).
RTNETLINK answers: File exists
Failed to bring up br0.                        [ OK ]

Try bringing down the device to be bridged (eth1) like this: sudo  ifdown eth1 and then issue sudo /etc/init.d/networking restart again.
After that enable it the device again again like this: sudo  ifup eth1
If this doesn’t worked try restarting the machine, worked for us.

When properly configured ifconfig should result to something similar as this:

br0       Link encap:Ethernet  HWaddr 00:1a:64:67:d3:86  
          inet addr:192.168.0.10  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:64ff:fe67:d386/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1752 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:136973 (136.9 KB)  TX bytes:1500 (1.5 KB)

eth0      Link encap:Ethernet  HWaddr 00:1a:64:67:d3:84  
          inet addr:10.16.20.60  Bcast:10.16.20.63  Mask:255.255.255.224
          inet6 addr: fe80::21a:64ff:fe67:d384/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:91218 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51796 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:123551183 (123.5 MB)  TX bytes:4754458 (4.7 MB)
          Interrupt:16 Memory:ce000000-ce012800

eth1      Link encap:Ethernet  HWaddr 00:1a:64:67:d3:86  
          inet addr:10.16.20.33  Bcast:10.16.20.63  Mask:255.255.255.224
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:2605 errors:0 dropped:48 overruns:0 frame:0
          TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:321878 (321.8 KB)  TX bytes:3490 (3.4 KB)
          Interrupt:17 Memory:ca000000-ca012800

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:129 errors:0 dropped:0 overruns:0 frame:0
          TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17588 (17.5 KB)  TX bytes:17588 (17.5 KB)

virbr0    Link encap:Ethernet  HWaddr b6:ae:8d:e0:06:c3  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)