Archive for the ‘Linux’ Category

How To Repair Images with ImageMagick

Monday, June 15th, 2009

I have been doing a lot of importing of photos on my photo site, and have noticed some images do not display properly. SinceI love ImageMagick so much,  I set up  my gallery to use it. However, there appears to be a check in the Coppermine software that aborts reading the file upon errors in the image. So I typed the command “display imagename.jpg” for some of the files that did not import properly, and everything appeared to be fine. But I did notice something peculiar about the images: they were taken with my phone’s camera and all had errors printed out when I tried to open them, but seem to display correctly.

Since these files could be opened by ImageMagick, I figured if I saved them again, I would be able to fix the errors. I ran “convert image1.jpg image1.jpg”, got the familiar errors printed and opened the file again. This time, no errors! But since I have a  lot of files I want to import, I needed a way to convert a bunch at once.

I created a neat little Perl script to do just that. All you need is ImageMagick and perl installed. This script does not rely on PerlMagick, as it runs the convert command. So here it is:

  1. #!/usr/bin/perl
  2.  
  3. processFile("$_") foreach (@ARGV);
  4.  
  5. #recursively fix images
  6. sub processFile {
  7.    my $file=shift;
  8.    return (-d "$file")?( do{ processFile("$_") foreach (<"$file"/*>) }) : `convert "$file" "$file"`;
  9. }

I saved this file as $HOME/bin/fiximage. All you need to do to run it is type “fiximage file1 file2 directory1 directory2 …”. One other thing to note is that this script has been purposefully shortened. I like to use the ternary operator whenever possible in my scripts for just this reason. As such, it does not print anything to the command line itself, but if the convert command encounters an error, that will be printed.

I hope you have found this article useful!

Windows vs. Linux on MSI GX700

Saturday, March 21st, 2009

When I built my desktop/server in 2005, I used as many MSI (Micro-Satr International) parts as I could find. They were a little more expensive, but some trusted friends told me MSI was the way to go. I have been overly impressed with the hardware, especially after an uptime of 500+ days. The systemwas extremely stable. Now I try to buy MSI products whenever possible.

So – Last summer I knew I would have enough money to finally buy a laptop of my own. I was looking for a Desktop replacement for school.  So naturally, I went in search of an MSI laptop. Since you can’t buy from the MSI web site, I had to go to a reseller, and RK Computers was MSI’s suggested reseller. For months, I looked at all the models and researched their specifications, as it had to run Linux and Windows. After my thorough evaluation, i decided to purchase a MSI GX700. Here are the specs:

MSI MS-1719 (GX700).
Display: WUXGA 1920 x 1200 Non-Glare-9 Cell Main Battery
MXM II Graphics Module: NVIDIA® GeForce® 8600M-GT 512MB VRAM + Turbo Cache-DX 10
Optical-DVD Or Blu-ray: Integrated Super-Multi Drive-Dual Layer
Core 2 Duo Processor: Intel Core™2 45nm T8300 2.40Ghz 3MB 800MHz
Compound-Heat Sink: Wet Arctic Silver 5 High-Density CPU Thermal Compound
2.5 Hard Drive: 320GB WD SATA II 5400 RPM 3Gbs 8MB Cache
Turbo Memory: No Turbo Memory-Windows Vista Support Only
Memory-DDR2 667: 4GB OCZ DDR2 667 PC2-5400 CL5 Dual Channel Kit
Wireless: Intel PRO Wireless 3945 802.11 a/b/g 11/54Mbps
Bluetooth: Integrated MS-6837D Bluetooth 2.0 + EDR USB Module
ExpressCard Remote: No Media Remote
NoteBook Cooler: Cooler Master Notebook Cooler Widscreen-USB Powered-Black
Operating System: No Operating System
Microsoft Office MLK: No Software
Warranty Options: 3 Year Parts-Lifetime Labor Warranty*-Lifetime Tech Support*
Total: $1878.04

Windows Vista 64bit

Since I was a student when I purchased this fine machine, I could get Windows Vista through the MSDNAA (Microsoft Develepers Network Academic Alliance). So I got down to it and installed Vista 32bit, because I thought programs would be more compatable. This turned out to be a mistake. Even though all of the software and drivers seemed to work fine, after only a few short days, I ran into problems (including a BSOD). I can’t remember exactly what those problems were, but I decided to switch to 64bit Vista. Now that I have experienced it, Vista seems to have been made for 64bit architectures. Everything ran so much faster and much more stable than its 32bit counterpart.

Problems

The only problem I encountered is that the software for the special buttons (MSVCtrl) won’t work under 64bit, even though they are 64bit versions. One other mention is that you have to use the nVidia graphics drivers from MSI’s web site, as nVidia’s version won’t work properly.

Fedora 10 x86_64

After installing Vista, I moved on to Linux. My first Linux distribution (“distro” for short) was RedHat 5, and I have been using RedHat or Fedora ever since. Fedora 9 installed and worked fine, but I will only be covering Fedora 10 here, as it is the current release and is a LOT more stable. Fedora 10 is a great distro, with a lot of features and software for just about anything. All of the laptop’s hardware works great in Fedora.

After installing Fedora, I went straight to the nVidia web site to get drivers for the graphics card. Since I am interested in programming, I downloaded the CUDA-enabled drivers. (Note: you do not need any special nVidia drivers like with Vista – just use the standard Linux drivers.) CUDA is a technology, created by nVidia, which allows programs to use the graphics card processor (GPU) as if it were another CPU. These drivers were extremely stable, even though they were a beta release. As of now, CUDA support is enabled, by default, for all of nVidia’s stable drivers (greater than version 1.80).

I was expecting to have a few problems with the wireless card, as Linux support for wireless cards is a little limited, but it works great with the default drivers. The integrated bluetooth works, as well.

Problems

There are a few problems with Linux in general on this Laptop. The on-board sound chip is an Intel High-Definition audio chip, and Linux doesn’t have the proper drivers for this yet. The sound works, but when you plug in headphones, the laptop’s speakers do not mute as expected. (I am currently pouring over Intel’s driver guide for this chip, and may end up hacking the current driver to fix this problem.) There are also no working drivers available for the integrated webcam.

So that’s it! This laptop is a great buy for anyone – whether you want to play games or just want a nice big screen to type up your latest best-selling novel.

Installing Aptana in Fedora Eclipse

Saturday, February 14th, 2009

Aptana is a wonderful tool for web design. I have been using it for years for my personal web sites and my professional ones. I have been trying to get more people turned on to it, as well. When I installed Fedora 10 recently, I didn’t want to install Aptana, as it has, in the past, FooBar’d my Eclipse installation. However, I am learning Ruby (on rails), and want to install RadRails, which means I need Aptana. I thought about installing Aptana standalone, but don’t want to start up a new Eclipse platform just for my rails development. So -

First, I tried to install Aptana normally, as an eclipse plugin, several times. However, some parts of it refused to work and the “My Aptana” page never showed up. After assessing this problem, I thought there may be conflicts with some of the plugins Fedora installs through yum. Ihad  installed all the Eclipse plugins that my yum repositories offered.

So I removed all the plugins using yum. Since I needed those plugins, I had to get the update sites to install in Eclipse. Here are the update sites for the rpms, for convenience. You can get the same information by checking the Fedora Eclipse project wiki at http://fedoraproject.org/wiki/Eclipse.

Keep Installed:

eclipse-ecj.x86_64
eclipse-demos.noarch
eclipse-platform.x86_64
eclipse-rcp.x86_64
eclipse-setools.x86_64
eclipse-shelled.noarch
eclipse-slide.noarch
eclipse-swt.x86_64
icu4j-eclipse.x86_64
tomcat5-jasper-eclipse.noarch

Install Using Aptana:

Subclipse (SVN Integration):
http://subclipse.tigris.org/update_1.4.x :

eclipse-subclipse*
Eclipse Git:
http://www.jgit.org/update-site/ :

eclipse-egit.noarch

Install Using The Update Manager:

Ganymede:
http://download.eclipse.org/releases/ganymede :

eclipse-cdt* (C and C++ Development)
eclipse-emf* (Model and Model Development)
eclipse-gef* (Graphical editors and frameworks)
eclipse-jdt* (Java development)
eclipse-mylyn* (Collaboration Tools)
eclipse-pde.x86_64 (Java Development/Eclipse plug-in development environment)

Maven Integration for Eclipse:
http://m2eclipse.sonatype.org/update-dev/
(stable development)
or http://m2eclipse.sonatype.org/update/ (stable)
maven2-plugin-eclipse.x86_64

Linux Tools for Eclipse:
http://download.eclipse.org/technology/linuxtools/update/ :

eclipse-changelog.x86_64
eclipse-rpm-editor.x86_64

Checkstyle Plugin:

http://eclipse-cs.sourceforge.net/update:

eclipse-checkstyle.x86_64

Eclipse Perl Integration:
http://e-p-i-c.sourceforge.net/updates/testing :

eclipse-epic.x86_64

Babel (milti-lingual support):
http://download.eclipse.org/technology/babel/update-site/ganymede :

eclipse-nls-*.noarch

Photran (fortran support):
http://download.eclipse.org/technology/photran/updates/eclipse3.4cdt5.0 :

eclipse-photran* (requires cdt plugin)

PHPEclipse (php):
http://phpeclipse.sourceforge.net/update/stable/1.2.x/ :

eclipse-phpeclipse.x86_64

Pydev (python):
http://pydev.sourceforge.net/updates/ :

eclipse-pydev*

QuickRex (regular expression editor):
http://www.bastian-bergerhoff.com/eclipse/features :

eclipse-quickrex.noarch

Now you are ready to install the Aptana plugin, using this update site: http://update.aptana.com/install/studio/3.2/. I recommend installing Aptan before installing any of the previously mentioned plugins, for best compatability.

That’s it and good luck!

Installing Gentoo 2008 in (qemu) Sun’s VirtualBox on Fedora 10

Monday, February 2nd, 2009

I am currently taking a class on Operating System design and need to do some kernel hacking for the class. I thought about modifying the Fedora kernel, but decided against it, as I still want a stable system to operate in.So I looked into virtual machines, as Fedora has qemu and a nice graphical virtd client for managing virtual machines. While deciding on my mainstay distro (in 2000), I evaluated the gamut of Linux distros, so I decided to install Gentoo linux on my virtual machine because it rebuilds everyting on the fly.
I went to the Gentoo site and downloaded the minimal install CD for ia64. No luck here – it won’t even boot, just hangs.
Then I downloaded the minimal install CD for amd64. I got into the boot loader and booted the system, but it hung on the kernel module loading step.
I finally decided to try a LiveCD. This worked beautifully. However, I couldn’t start an X session, as the appropriate driver was not included on the CD. No real need, as I was installing it on my disk image. So I ran /opt/installer/bin/install and now it is installing fine. It is taking quite a while to install, however, and I hope to have it finished by the end of the day. (I have classes all day, and will resume install this evening.)

[more to come later...]

So I scrapped the idea of installing Gentoo on qemu. I t was just too slow and too much of a pain. So I decided to try out Sun’s VirtualBox for the first time. I really like it! On my machine, it is faster than qemu and VMWare. The reason for testing on VBox is that qemu doesn’t really support 64 bit OSs. I also wanted something that could take advantage of my hardware, and VMware does an OK job, but not at the level I want. It seems that VBox is everything I wanted, and i get speeds of almost the same as my host platform. I am running a benchmark program, nbench, and will post the results here when I finish.

nbench result for host OS (Fedora 10 x86_64 on Intel Core 2 Duo w/ 4Gb RAM):

BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          1165.6  :      29.89  :       9.82
STRING SORT         :          258.88  :     115.67  :      17.90
BITFIELD            :      4.6794e+08  :      80.27  :      16.77
FP EMULATION        :          251.44  :     120.65  :      27.84
FOURIER             :           25958  :      29.52  :      16.58
ASSIGNMENT          :          34.798  :     132.41  :      34.34
IDEA                :            7068  :     108.10  :      32.10
HUFFMAN             :          2325.1  :      64.48  :      20.59
NEURAL NET          :          50.819  :      81.64  :      34.34
LU DECOMPOSITION    :            1652  :      85.58  :      61.80
==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 84.556
FLOATING-POINT INDEX: 59.082
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : Dual GenuineIntel Intel(R) Core(TM)2 Duo CPU     T8300  @ 2.40GHz 800MHz
L2 Cache            : 3072 KB
OS                  : Linux 2.6.27.12-170.2.5.fc10.x86_64
C compiler          : gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) 
libc                : libc-2.9.so
MEMORY INDEX        : 21.765
INTEGER INDEX       : 20.615
FLOATING-POINT INDEX: 32.769
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
* Trademarks are property of their respective holder.

nbench result for Gentoo 2008 x86_64 on Sun VirtualBox (w/ 768 Mb RAM):

BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          1139.8  :      29.23  :       9.60
STRING SORT         :          250.16  :     111.78  :      17.30
BITFIELD            :      4.2657e+08  :      73.17  :      15.28
FP EMULATION        :          108.16  :      51.90  :      11.98
FOURIER             :           20163  :      22.93  :      12.88
ASSIGNMENT          :          34.385  :     130.84  :      33.94
IDEA                :            4207  :      64.34  :      19.10
HUFFMAN             :          2259.9  :      62.67  :      20.01
NEURAL NET          :          44.636  :      71.70  :      30.16
LU DECOMPOSITION    :          1589.6  :      82.35  :      59.46
==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 67.742
FLOATING-POINT INDEX: 51.348
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : Dual GenuineIntel Intel(R) Core(TM)2 Duo CPU     T8300  @ 2.40GHz 2399MHz
L2 Cache            : 64 KB
OS                  : Linux 2.6.27-gentoo-r8
C compiler          : x86_64-pc-linux-gnu-gcc 
libc                : 
MEMORY INDEX        : 20.781
INTEGER INDEX       : 14.479
FLOATING-POINT INDEX: 28.480
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
* Trademarks are property of their respective holder.