Wednesday, November 11, 2009

Installing ImageMagick on Fedora 8 Linux VM

There was a relatively old version of software installed, so I preferred to install from source instead of 'yum install ImageMagick' who told me 'there is no new versions'. I should be verifying why my repositories say that, I know...

Anyway, it was a very easy task. Here are the simple instructions how to install from source: http://www.imagemagick.org/script/install-source.php#unix

Summarizing that, there are just a few simple commands (you should get root permissions or use 'sudo make install' instead of 'make install' below)

tar xvfz ImageMagick.tar.gz
cd ImageMagick-version
./configure
make
make install


'make' took some time, but 'make install' on my machine failed with:
'Can't locate ExtUtils/MakeMaker.pm' error in Makefile.PL

I solved this by installing the missing package:

yum install perl-ExtUtils-MakeMaker


and running 'make install' again. Running

convert logo: ml.gif


silently created an ImageMagick logo image that can bee viewed in 'ml.gif'

Done

Installing MagickWand for ImageMagick with XAMPP / PHP on Windows

XAMPP comes with ImageMagic. Check you see this section running phpinfo():


imagick
imagick module enabled
imagick module version 2.0.0-rc1
imagick classes Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator
ImageMagick version ImageMagick 6.3.3 04/21/07 Q16 http://www.imagemagick.org
ImageMagick release date 04/21/07
ImageMagick Number of supported formats: 164
ImageMagick Supported formats A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CACHE, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CUR, CUT, DCM, DCX, DFONT, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, INFO, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MSL, MSVG, MTV, MVG, NULL, O, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PFA, PFB, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV


If you got it, you have ImageMagick installed. If you do not see this section, install ImageMagick first: go to http://www.imagemagick.org

Next, if you are lazy like I am install a compiled version of MagicWand.
Get the binaries here: http://www.dirk.sh/dirk/magickwand/
I used php-5.2.4_magickwand_q16_st.dll and it seems to work fine.
Alternatively, get the source code from http://www.magickwand.org and compile it by yourself.

Put the DLL into PHP extensions directory. If you are not sure where it is, look into your php.ini file for a line like
extension_dir = "C:\xampp\php\ext\"

There are at least two php.ini with XAMPP for Windows distribution. The correct one is located in your-xampp-installation-folder\apache\bin, e.g. "C:\xampp\apache\bin\php.ini"

Define the new extension by adding to php.ini a line like this:
extension=php-5.2.4_magickwand_q16_st.dll

Restart Apache

Verify that phpinfo() now shows the MagickWand table:


magickwand
MagickWand Backend Library ImageMagick
MagickWand Extension Version 1.0.5
ImageMagick support enabled
ImageMagick version ImageMagick 6.3.5 09/21/07 Q16 http://www.imagemagick.org
ImageMagick QuantumRange (MaxRGB) 65535
MagickWand supported image formats A, ART, AVI, AVS, B, BIE, BMP, BMP2, BMP3, C, CAPTION, CIN, CIP, CLIP, CLIPBOARD, CMYK, CMYKA, CR2, CRW, CUR, CUT, DCM, DCR, DCX, DFONT, DNG, DPS, DPX, EMF, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, EXR, FAX, FITS, FRACTAL, FTS, G, G3, GIF, GIF87, GRADIENT, GRAY, HISTOGRAM, HTM, HTML, ICB, ICO, ICON, INFO, IPL, JBG, JBIG, JNG, JP2, JPC, JPEG, JPG, JPX, K, LABEL, M, M2V, MAP, MAT, MATTE, MIFF, MNG, MONO, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NULL, O, ORF, OTB, OTF, PAL, PALM, PAM, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PEF, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG24, PNG32, PNG8, PNM, PPM, PREVIEW, PS, PS2, PS3, PSD, PTIF, PWP, R, RAF, RAS, RGB, RGBA, RGBO, RLA, RLE, SCR, SCT, SFW, SGI, SHTML, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UIL, UYVY, VDA, VICAR, VID, VIFF, VST, WBMP, WMF, WMFWIN32, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XV, XWD, Y, YCbCr, YCbCrA, YUV


You are mostly done now.

Test your installation with the PHP code like this


$resource = NewMagickWand();
MagickReadImage( $resource, 'D:\test.jpg' );

header( 'Content-Type: image/jpeg' );
MagickEchoImageBlob( $resource );


And look here for some more PHP / MagickWand / ImageMagick code snippets.

Also note this nice post, however the links to ImageMagick binaries there do not work anymore.

Friday, June 05, 2009

Inside AdWords: New Interface Thursdays: Exploring the Ads tab

Inside AdWords: New Interface Thursdays: Exploring the Ads tab
Well, I tried the new interface and due to multiple processing errors I meanwhile switched back to the old one, thanks G. :-) it is still available.
Working with Adwords-online this time, I found a strange limitation of maximum 50 ads in the same ad group. I believe it exists in both old and the new UI, seems that the limitation should be at the server side.

I just wanted to put in about 25 ads, each one delivered in 8 Google' banner formats - from 468x60 to 160x600. Yes, I wanted to put them all in the same adgroup but I could not do that because of this stupid 50-max limit.

Google forced me to open new ad groups in the same ad campaign (I never wanted that) and put my extra- banners there. I ended up with 3 ad groups instead of just one because of 50-ads max limitation. (3 but not 4 groups because not all the ads where delivered in all sizes).

Now, I have to manage separately these 3 ad groups - their keywords, bids etc. Obviously, this is not what I want to do - it wastes my time without any return.

So, dear Google, would you please remove this weird 50-max ads limit, letting me to do my job faster? I need it much more than WEB2-like new UI you guys have introduced. I do not say it is baaad, it is just still to young to work properly with all the AJAX involved. Is not it enough that Microsoft treat their users as testers, delivering them new OS that should never leave their lab, now Google is going the same way?

Thursday, May 21, 2009

mySQL FULLTEXT search returns no results: ft_min_word_len

MySQL FULLTEXT search query worked well until I tried to find "boy" in my DB.
No results, and I can see some records with this word directly on my phpMyAdmin screen.
The same repeated with the word "red". It can find, "blue"< "green" and "yellow", but not "red".

Well, after some searching I found that FULLTEXT in mySQL has two server variables (well, it have more of course, but these two are relevant for this issue):
ft_min_word_len = 4
ft_max_word_len = 84

Words less than 4 chars will not be indexed until you change ft_min_word_len to something less than 4 chars.

So, on Redhat/Fedora and many other Linuxes you have to edit /etc/my.cnf
The addition might look:

[mysqld]
ft_min_word_len=1
ft_max_word_len=32

Note [mysqld] header - if it is already in that file, just put two lines woth ft_ under it. It's important! If you put it under another header mySQL will not recognize it. Cost me about 2 hours two figure this stupid thing out since typically "[...]" headers are ignored by the parsing software (used as comments).
But obviously, not in my.cnf and mySQL.

On Windows with XAMPP there is a file called "my" (just "my", now extension whatsoever) in /mysql/bin folder.
It's the same my.cnf, so just add the lines into [mysqld] section there.

Verify that the change worked in phpMyAdmin ->localhost -> Varaibles

The last thing to do to get the things working is rebuilding all FULLTEXT indexes, if you got some data in the DB yet.
With phpMyAdmin you can just click "edit" link next to the FULLTEXT index name, and when the edit screen opens, click "Save" button. You will see that mySQL runs actually 'drop the old index and create the new index" query.

Monday, March 30, 2009

Switching between different Java versions, Java 5 instead of Java 6

Since like many of you I am developing multiple projects simultaneously and have a very heterogeneous environment on my Windows machine, I always looked for a simple way to switch between the latest Java version and the previous one, which I still needed for some older projects.
Once installed, the latest JRE/JDK (currently, Java 6) become the JVM of choice for any app in Windows OS and it was quite tricky for me to force an app to be executed under Java 5.

I saw many posts on the Internet claiming they solved the issue by manually
editing Windows registry and/or replacing soem files in Windows/system32 directory - never wanted to do that.

This post is probably the closest to what I wanted to do, however the code from this post did not work 'as is' in my batch files.

Looking at java.exe command options in Java 6 I found an amazing feature:
-version:

This is what the command line java says about it:
-version:
require the specified version to run

Sounds just what I needed! So I run it like this:
>java -version:1.5.0_17 -version

And voila! - here is what says my Java 6 now:
java version "1.5.0_17"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_17-b04)
Java HotSpot(TM) Client VM (build 1.5.0_17-b04, mixed mode)


Of course if I run it with just -version (no ":" and no alternative JRE/JDK), it keeps saying:
> java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

Sunday, March 01, 2009

NetBeans debugger does not stop on breakpoints

If NetBeans shows you that a debugger is running, however you can not stop it on breakpoint and the "Set In/Step Out /etc" menu is grayed out, it quite sure means that your debugger is not properly configured. Follow this post to configure your debugger to work with NetBeans properly.

Configuring Xdebug with XAMPP for NetBeans and Eclipse, Windows 7 and Win XP

UPDATE: Since XAMPP 1.7.2 + PHP 5.3 the things get much easier. Here is the quote from NetBeans web site, and it works! With this XAMPP version the only php.ini is located in \php

Xdebug on XAMPP 1.7.2 (PHP 5.3)

  1. Locate and open XAMPP_HOME\php\php.ini for editing. This is the only php.ini file in XAMPP 1.7.2.
  2. Find and uncomment the line zend_extension = "XAMPP_HOME\php\ext\php_xdebug.dll".
  3. Find and uncomment the line xdebug.remote_host=localhost. Change the value of the setting from localhost to 127.0.0.1.
  4. Find and uncomment the line xdebug.remote_enable = 0. Change 0 to 1.
  5. Find and uncomment the line xdebug.remote_handler = "dbgp".
  6. Find and uncomment the line xdebug.remote_port = 9000.
  7. Save php.ini.
  8. Restart the Apache server.

============ For old XAMP 1.7.0 ==================================
Installing NetBeans was easy. The more difficult part was configuring and making the PHP debugger work.
I have XAMPP installation on my Win XP and NetBeans uses Xdebug (http://www.xdebug.org), so I assumed it will be quite easy to configure all the stuff. Well, it was not that easy just because there is a missing link in NetBeans docs speaking about Xdebug config with XAMPP.

For XAMPP you should work with [xamp-dir]/php/php.ini. In fact there is another php.ini in /apache/bin - do not worry aboput it, it is just a shortcut to the first one.

First, make sure that anything in Zend section in your php.ini is commented out:

[Zend]
;zend_extension_ts = "C:\xampp\php\zendOptimizer\lib\ZendExtensionManager.dll"
;zend_extension_manager.optimizer_ts = "C:\xampp\php\zendOptimizer\lib\Optimizer"
;zend_optimizer.enable_loader = 0
;zend_optimizer.optimization_level=15
;zend_optimizer.license_path =
; Local Variables:
; tab-width: 4
; End:


Next, (IMPORTANT!) find the line
extension=php_xdebug.dll

and comment it out, so it becomes to be
;extension=php_xdebug.dll

That's seems strange and illogical, but trust me you must do it to get the things work. This is missed from most posts / threads RE Xdebug / Xampp, only few of them mention it.

Next, edit Xdebug section of your php.ini to look like:

XDebug]
;; Only Zend OR (!) XDebug
zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_portjavascript:void(0)=9000
xdebug.remote_mode=req
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"

Now, restart Apache and point your browser to a PHP file with phpinfo().
You should see that xdebug appears twice in your phpinfo():
- once near the Zend Engine 2 logo, with text similar to

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.4, Copyright (c) 2002-2008, by Derick Rethans

- and the second time much lower at that page, with the tables showing something like:

xdebug
xdebug support enabled
Version 2.0.4

Supported protocols Revision
DBGp - Common DeBuGger Protocol $Revision: 1.125.2.6 $
GDB - GNU Debugger protocol $Revision: 1.87 $
PHP3 - PHP 3 Debugger protocol $Revision: 1.22 $


If you do not see either of this appearances your configuration is incorrect!
Also, if you see the table with "Xdebug support" text, but there is a text saying "XDEBUG IS NOT INSTALLED AS ZEND EXTENSION" your configuration should be fixed.

Now, if you are done with that, go to Xdebug web and pick one of the latest Xdebug dlls. Put it in your [xampp-dir]/php/ext folder and change in php.ini the line

zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"
to point to the new dll, i.e.
zend_extension_ts="C:\xampp\php\ext\php_xdebug-2.0.4-5.2.8.dll"

"_ts" means thread safe, so you need a thread-safe dll version from Xdebug web.
Note that NOT all thread safe version found there will work with XAMPP. I am not sure why, but from the latest release only php_xdebug-2.0.4-5.2.8.dll works as it is expected, others e.g. php_xdebug-2.0.3-5.3.0.dll or php_xdebug-2.0.4-5.3.0-vc9.dll just does not worked for me, showing "XDEBUG IS NOT INSTALLED AS ZEND EXTENSION" or just disappearing from the phpinfo() at all.

Now save php.ini, restart Apache and verify that you see Xdebug info in two locations in phpinfo(), like it is explained above. If you got it working, both NetBeans and Eclipse PDT will be able to work with Xdebug now