Remove Part of File Names using PHP
Since David’s Batch Processor was pre-installed in GIMP on Ubuntu Studio, I used it extensively in the ICAF Gallery project today. My goal for these images is to resize their thumbnail version to 10KB or smaller and retain the original size for the enlarged version. Because most of these images are in different resolution, I randomly selected the scale value in the Batch Processor to resize the images. Then I had to manually view the file size of each image to see whether or not an image has to be resized again. After the differentiation, I moved the images that need to be resized once more to a new sub-directory and started the above process one more time. I would repeat these steps again and again until all the thumbnail version of the images are under 10KB.
During the early use of the Batch Processor, I missed a very important feature that is to save the newly processed images to a different folders. This resulted my decision to write this Batch File Name Remover script. The source code for this script is very easy to understand. It’s just some PHP functions plus two Linux commands: ls and mv. I always place a postfix after the file name of processed thumbnails: “-thumb”. Because of that, I need to remove this postfix whenever I repeated the above resize steps. The ls command is used to list the file name that contains the specified characters into an array. The mv command is used to remove the specified characters from the file name using PHP explode function. I used PHP instead of native Linux Bash script because PHP is easier than Bash for me
. The source code for this script is available here.
Below is the Batch File Name Remover in action:
Transitioning to Ubuntu Studio

Yesterday I switched to Ubuntu Studio 10.04 mainly because I love the audio production tools available in the distro. The first time I tried to install Ubuntu Studio from the original DVD was a failure. That’s probably because this distro is usually for multimedia workstation, therefore it doesn’t install NetworkManager by default. As the result, I didn’t get very far with this original distribution because of the wifi struggle.
Instead, I reinstalled Ubuntu 10.04 and upgraded to Ubuntu Studio by following this Ubuntu Documentation article. Here is the video preview of the Application menu in the Original Ubuntu Studio:
Note that I installed the distro inside VirtualBox using original DVD ISO image in the above video to show the different default interface between Ubuntu and Ubuntu Studio. The version of Ubuntu Studio upgraded from the original Ubuntu installation is very different, notably the NetworkManager.
I’m currently in the process of transitioning to this new Ubuntu environment. I have many tasks to complete like deciding which applications to reinstall and restore their configurations from my backed up home directory, etc. Once I finished all these tasks (probably today), I will start to learn about the tools available in Ubuntu Studio like LMMS and StopMotion. Look forward to the upcoming posts about these tools.
Running Sims 3 under PlayOnLinux in Ubuntu Linux
Back when I was using Windows Vista years ago, I played The Sims 3 and other games for several hours. Once I switched to GNU/Linux, I got rid of these games when I failed to run them under Wine. However, for some reasons, I found a folder which stores The Sims 3 ISO file while cleaning and organize the hard drives today that I downloaded from a website that I don’t remember anymore. I searched over on the Wine database and found that the game and its expansion packs are in the gold state which I assume that it works very well on the GNU/Linux platform.
After searching around in the Ubuntu repositories, I discovered PlayOnLinux which is the front-end of Wine. I installed it and found out that there are almost all the Windows software and games that are pre-configured by PlayOnLinux. One thing that I discovered when I was running The Sims 3 under PlayOnLinux is that the sound would go out about one minute after running the game. The following is the solution that I came up with the help of this PlayOnLinux forum thread:
- Open the terminal and type playonlinux to run the GUI which you can add to the GNOME Menu manually with this command. Read this article on detailed instructions on how to do this.
- Install the game by clicking the Install button on the toolbar and follow the instruction.
- Run the game you installed. If it doesn’t have any sound problem, enjoy the program. Otherwise, go on to the next step.
- Follow the instruction on the first post of this thread under the FIX section.
- Instead of using last step on that thread, create a launcher on the desktop with the following information:
Type: Application
Name: The program name that you installed in step 2. In my case is Sims 3.
Command: padsp playonlinux –run “The Sims 3″
(Replace The Sims 3 with the program name that you want to run, note that this name must exactly the same with the name listed in the PlayOnLinux main window, otherwise it will fail to run)
Comment: Optional. You can add your own description. - You can add an unique icon by clicking the button on the left and select a JPG image.
- Click the launcher that you created and enjoy the game.
- You can also add this launcher to the GNOME menu by following the instruction from the link I provided in step 1.
If you have any problem for the above steps, leave a comment below and I will try to help as quick as possible. Note that I will not answer comments other than sound problem, especially the CD-related issue for the legal concern of my hosting provider.
Linux Shell Programming Basics
I have been reading Wrox Beginning Linux Programming this week. The book mainly teaches how to programming in GNU/Linux using C. Since I’m learning the basics of C, I thought I could understand some of the materials in this book. In Chapter 2, it talks about shell programming and how does it relate to C programming in GNU/Linux. I wrote the following code which is based on the example code in Chapter 2:
#!/bin/sh # This file looks through all the files in the current # directory for the input string, and then prints the name of # those files to the standard output. echo "" echo Enter the lookup value: read input echo "" for file in * do if [ -f $file ] then if grep -q $input $file then echo $file fi fi done echo "" exit 0
And the screenshot below is the output:
Click the image to enlarge
Note that the read command is similar to the scanf function in C. They are used to let user input value. Also note that this script would take a moment to complete depending on the size of each file where the script file is in.
If you have this book, the above script is similar to the example provided in the Chapter 2 of the book, except I removed static input value (POSIX) and added an user input field using read command and several blank lines to make the output more cleaner.
Linux movies website overview
I watched some psychology related films today because of my recent interest for multiple personality disorder (now called dissociative identity disorder). Therefore I don’t have much to write about GNU/Linux or web development. However, I’m going to talk a little bit about a website called linuxmovies.org. This website is about how the movie studios use GNU/Linux to create special effects for the movies. As those of you who followed my Twitter and/or identica feed, I already talked about the site. For this post, I will focus on the Software section. When I first arrived on this page, I only scrolled down to look for the free software. Perhaps it is my habit to believe that only free and open source software should be used on the GNU/Linux OS. Unsurprisingly, there are greater number of free software than commercial software. After looking through the list, I have chosen K-3D, including Blender, GIMP, and Audacity which I’ve already been using. After some usage of K-3D, I personally think that this program is easier to use than Blender once I know the basic usage of the program. Unfortunately, I’m not interested in art very much. Therefore I don’t fell that K-3D has any use for me, except when I want to improve creativity and get some inspirations for my upcoming projects.
Use Rhythmbox to sync with iPod Touch
Today I happened to be downloaded a music album online and an audio book from Librivox. I want to transfer them to my iPod Touch. The first program that I remembered to have iPod Touch/iPhone sync ability is Rhythmbox so I launched the program. After playing around its interface, I was beginning to love to use Rhythmbox.
Once I started Rhythmbox from the Sound & Video menu, I had to left-click the music player icon on the status bar and select Show Rhythmbox. The name of my iPod Touch was already listed under Devices, I just needed to add the music and audio book files that I downloaded. It automatically added the files when I dragged and dropped the downloaded files into the Music Player window. Rhythmbox doesn’t seem to support transfer the files directly to the playlist created under iPod Touch. I had to first copy the music files to the root of my iPod Touch and then drag them to the playlist.
The music album I downloaded works great on my iPod Touch, but it doesn’t recognize the audio book files as audio book even I converted them from mp3 to m4b using XCFA. Since Librivox provides separate chapter files for each audio book, I don’t care about using audio book feature in iPod Touch very much.
Text-to-speech web service Odiogo (Updated)
Update(06/01/2010 10:30 AM): The audio version of this post is now available. You can click the above “listen now” button to listen to this post.
Update (05/31/2010 11:25 AM):Â Apparently, Odiogo hasn’t converted this newest post to audio yet. According to their FAQ, they check the update several times throughout the day. However, it has been almost twelve hours since this post was written, the audio version of this post hasn’t been available yet. I will update this post as soon as the audio version of the post is available. In the meanwhile, you can checkout the TTS version for my other posts on this blog.
While I was reading the news today, I came across an article on freesoftwaremagazin.com. A feature on the site that interests me is the “listen now” button. When I clicked on it, a familiar male TTS (Text-To-Speech) voice began to read the current article aloud for me. This voice is very familiar to me because I always used TextAloud with this Neospeech Paul voice to read the articles online when I was a Windows user. This voice is very human-like compare to Neospeech’s own female voice. After I switched to GNU/Linux for the first time, I tried to install TextAloud and the Paul voice through Wine, but I failed. Because I was too relied on the TTS reading the articles for me, my reading speed have become slow. I then decided to challenge myself to read myself since that day when I gave up installing TTS engine and TextAloud onto GNU/Linux. However, I still think that my reading haven’t improve at all. When I heard this voice on the website, the above memory came up in my mind. I can’t help but to look for where to produce this voice. Fortunately, it contains an introductory voice in the audio that talks about the source of this feature. It’s odiogo.com. At first, I thought that this web site provides web services that can use TTS on other websites to help me read the articles just like TextAloud. However, it seems that it used to convert my own blog to podcasts. It disappoints me to know that it can’t work on websites other than my own site, but I think that it is a good idea to provide more accessibility to my blog through this web service. Therefore, I added a “listen now” button onto this blog to provide text-to-speech feature. Check it out now below the title of this post and tell me what do you think in the comment.
Created a new logo
I decided that the logo redesign is my next step for the project. Blender and GIMP are two editors that I used to design the current logo. The tools I used to create redesigned logo are Inkscape and GIMP. I used Inkscape to design the basic text and add shadow and reflection effects using GIMP. This is the first time I have used Inkscape so I only can discover its features through using it. I found out that it has the ability to directly change the font size without converting the text to image like GIMP does. This means that I can change the content of the text after I changed font size. Inkscape also has drag and drop feature to import different image files into the document, including JPG and PNG. Below is my finished text created using Inkscape:
The file saved by Inkscape is a SVG file. It can be imported into GIMP as an image file. By following this tutorial, I was able to create a shadow effect for the logo, as well as the reflection effect. Below is the logo with effects added:

This image is directly linked from beta.robbychen.com
Note that this logo might change based on the future development of the site. For instance, I might add or remove some open source software images, such as Ubuntu logo for letter o in my name. However, I will write a post about the change once I make a change on the beta site.
Manage files using PHP on Linux Server
I have been playing around with my Ubuntu Server recently and found out that I have to use SSH each time I need to use the server. This remained me of PHP backtick operator, which has the ability to execute Linux command using PHP. This means that I can write a PHP script to manage the files on my server using Linux commands that I already knew without SSH.
Since I can’t connect my server to the outside world because of Verizon, I don’t have any security risk to change the files permissions on my server to 777. I then wrote the following code to show the list of files/directories under the web server root:
$command = `ls`;
$list = explode("n", $command);
$lslist = "";
foreach ($list as $lsLx) {
   echo $lsLx . "<br />";
}
Here is the code I wrote to use different parameters of li command. For instance, li -a shows all of the files/directories including the hidden ones and li -l shows the long list format.
I want to write a web UI to use with FFmpeg since I use it most of time on my server to convert videos to ogv format. The above code is just my concept of how to use PHP form to execute Linux command dynamically. It enabled me to use it as a base of designing the Web User Interface for Linux commands.
