Thursday, January 21, 2010

Convert PS and EPS files into JPEG

I got this useful information from this link.

You can convert any ps or eps file into a jpeg using ghostscript:

gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=myfile.jpg myfile.eps


This method has one flaw. It produces huge files. Depending on the eps file you may get something like 2000×3000 pixels which is slightly on the insane side. Also the file size of the JPG will be about 10 times that of the eps.
We will now need to trim and resize the file using some Image Magic tools:


mogrify -trim -resize 800x600 myfile.jpg


In order to execute this command on multiple files,  use following bash script

for k in $(ls *.eps); do b=`basename ${k%.eps}`; gs -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r300 -sOutputFile=$b.jpg $k; mogrify -trim -resize 800x600 $b.jpg; done
 

Saturday, January 9, 2010

Linux on windows: Cygwin

If you use applications that work on only windows (like gtalk, voipcall clients), then you feel like having linux environment on the side, so that you won't have reboot into linux for doing your work. For these people (including me), Cygwin is a good choice. For instance you can have the bash shell, emacs, gnuplot, xfig, gvim, latex, xdvi all at one place ...  The installations is very easy.  Don't forget to install X server of cygwin (cygwin/x) during the installation process. Particularly, latex is more neat to use on cygwin than installing miktex and other tools for the same purpose.

Sunday, August 23, 2009

deprecated conversion warning for char* in GCC

g++-4.x gives following warning whenever a string with in double quotes is assigned to a char * :

warning: deprecated conversion from string constant to ‘char*’

Though there is no fix available as far as I know except for following two solutions:
1. convert 'char *' to 'const char*' whenever a string is to be assigned.
2. use a type cast to convert a string to a char*.

For example:

const char *name = "Adam Smith"
char *name = (char*) "Adam Smith"


To get rid of deprecated conversion warning, pass -Wno-write-strings option to g++

opencv on Ubuntu Jaunty

Opencv does not handle videos properly on Ubuntu Jaunty. In order to fix this, please follow the instructions given at this link:

http://gijs.pythonic.nl/blog/2009/may/3/getting-video-io-working-opencv-and-ubuntu-jaunty-/

Monday, August 10, 2009

Vim-latex suite on Ubuntu Jaunty

First install vim-latex package using synaptic packet manager. Then run following command on a terminal :

$ sudo vim-addons -w install latex-suite

Now opening a tex document with gvim should show tex related menus on the menu bar.

If this does not help, then refer to ubuntu forums for solution. For instance check this link.

Friday, July 10, 2009

Automating chmod

Task is to change the permission modes for multiple directories

$ find . -type d -print0 | xargs -0 chmod 771

Tuesday, June 30, 2009

PDF Highlighting tool


Earlier I talked about few tools for editing PDF files (for free) on linux. You can go through the discussion here. I recently came across some more free tools that tend to make our life little easier, particularly when it comes to editing pdf files on linux. Some of these tools are as follows:
  1. Scribus : Limited capabilities
  2. Inkscape : Limited capabilities
  3. Okular : Limited capabilities. You can do some highlighting and add annotations. But they don't seem to be very neat. Just give a look at some screenshots.
  4. PDF-xchange-viewer. Its a windows based application which is free to download at present and can be run on linux using Wine. I could use it flawlessly on my Ubuntu Intrepid Ibex (8.10). Among all pdf editing tools, this seems to the best option for editing pdf files. Even though its not a native linux application, it is better than going back to windows just for editing a PDF file. However, I am still waiting for GNUpdf which, I believe, would provide a permanent relief to linux users in this regard.

    To get started, first use synaptic packet manager to install wine. For Ibex, follow the instructions given at this link. Download PDF-xchange-viewer from its website and run it using wine. That's all. It installs itself within a folder. A screenshot of PDF-xchange-viewer is shown in the adjacent thumbnail. Its really neat and close to what we find in Adobe Acrobat PDF editor.
  5. PDFescape: You can edit PDF files online (particularly fill up forms) at this website. This is useful if you are in a hurry and can't install a PDF editing software on a public machine.

Update: November 10, 2014

Wine does not support PDF-xchange-viewer properly. It crashes frequently. You may think of buying crossover to run PDF-xchange-viewer. Another alternative is to use Master PDF Editor. IT is pretty decent for highlighting and adding texts. It still does not have features to include boxes and circles.  

Installing Master PDF Editor is not very complicated. The following commands worked for me on a Linux Mint 17 machine (copied from here ... ):

$ wget -c http://code-industry.net/public/master-pdf-editor_1.9.25_amd64.deb
$ sudo dpkg -i master-pdf-editor_1.9.25_amd64.deb