Sunday, March 11, 2012

Color- Synchronization between html and gd library

Is there any differences in color codes in php-gd library and html? When I pick a color and send it to script, it doesn't look same. I need to find out a procedure to make them synchronized.

Oh, I got a point, ##F0F8FF is a hexa-decimal representation of color, which is widely used in html and supported by all browsers. But, I should use different format of color code except hex which is similar to gd library's way of color recognition. Usually GD makes color from intensity of green, red and blue. I can also use this same format for html by using rgb($red, $green, $blue) instead of hex. Hope, it will help me.

Now, I have to think about dynamic use of this format which will come directly from my database. I think, if I use '-' as delimiter then it will be perfect. I will generate html and gd script from the same think as they require by deleting '-' and using the real values.

This way I could solve my problem.

Saturday, March 10, 2012

FFMPEG-PHP! Made me tired

It is almost two weeks, I have started working on something which requires ffmpeg-php extensions. Downloaded some classes, none of them worked, because I was using windows platform, and ffmpeg decoders still don't like to work with windows. Oh, I have to go back linux again. Sarmed Vai suggested me to test linux at Oracle VirtualBox. That helped me a lot, because I had to install, re-install and uninstall different distributions of linux, direct installation could make my pc gone-forever.

Ubuntu couldn't help, it's not completely perfect for server things, but for personal use, it's awesome. And there is another version may be exist which is for making a server, but I had no cd of that. Gave up after multiple trial, then downloaded CentOS (again suggested by Sarmed Vai).

I had to install apache (httpd), php, mysql etc, and also ffmpeg, I am now going to tell you how I tried to install ffmpeg in CentOS.

Tried the following commands at terminal:

cd ~
mkdir ffmpeg
wget http://dfn.dl.sourceforge.net/sourceforge/ffmpeginstall/ffmpeginstall.3.2.1.tar.gz
tar zxf ffmpeginstall.3.2.1.tar.gz
cd ffmpeginstall.3.2.1
./install

I saw many things on screen, but don't know if it is really done. Just tested some functions, but couldn't see any progress. I quit. I did this procedure for multiple times, and in different distros. Now, I should to wait for a help.

I think I have to think about windows again. Let me do some search in google, found some posts, but not sure if they can help me.

It didn't help, followed the complete procedure, but it's not working. It's a nightmare for me, I lost lots of hours for doing this, and could not make it, Dhaaaaatt....

Thanks to Muntasir Rashid, he just have given me a ffmpeg-php enabled hosting. Just checked a function for making a thumbnail from a video, and wow! it is created successfully. Now, I have to make a video from set of pictures.

Got another way to install ffmpeg-php in my CentOS server.

Already did the following procedures:

1. Added a file: "/etc/yum.repos.d/dag.repo" with following contents to add a 3rd party yum repository:

[dag]
name=DAG RPM Repository
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1

2. Ran following commands:

rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
rpm --import RPM-GPG-KEY.dag.txt

3. Tested the setup using the following command:

rpm -q gpg-pubkey-*

Got some multiple line output like: gpg-pubkey-e8562897-459f07a4

4. Then updated "yum" by the command: yum update
5. Installed ffmpeg using the command: yum install ffmpeg ffmpeg-devel
6. Downloaded and installed ffmpeg-php using the following command:

wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download

tar -xjf ffmpeg-php-0.6.0.tbz2

cd ffmpeg-php-0.6.0

7. Some geniuses think there is an error in the file "ffmpeg_frame.c", I replaced all "PIX_FMT_RGBA32" patterned text into "PIX_FMT_RGB32". Hope, it will work.

8. Then I had to configure ffmpeg-php using the following command:

phpize
./configure && make
make install

Here, I had to fall in a situation. phpize command doesn't work. I tried to install php-devel by the command "yum install php-devel" and after it's installation, "phpize" command worked.

Then, I had to add the extension to /etc/php.ini by adding the following line:

extension=ffmpeg.so

Now, I have to check if it really works.

Alhamdulillah, it works.

Testing Webserver (httpd) at VirtualBox

Now, my challenge is to browse websites hosted in CentOS which is running in a VirtualBox window. Already installed httpd, php, mysql, perl etc. and they are working fine. I could manage to test a script using text based web browser lynx.

Now, I am going to try from host pc using graphical browser. I'll have to define a ip address at guest CentOS then try to browse it.

Before starting, I have to change network settings of virtual box for CentOS installation. I changed it at virtualBox>Settings>Network>Attached to, choose "Host-only Adapter" then clicked "Ok". Now it's ready for doing the rest.

I forgot the way how to change ip, searching, but finding nowhere. What happened!! Better keep searching my notes of my B.Sc networking classes. I don't know where to find them. Wow, I have found those notes, but they are about Red Hat, I have to make them useful for my current CentOS.

Yeah, I can now browse hosted files from guest pc. Let me tell what I have done:

First, I have checked virtual host-only network ip address of host pc.
Then, I have edited ip address of guest "centos" by the following command prompt codes:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

pressed "i" for inserting text into the script, started from at end of the lines there. Added these following lines:

BOOTPROTO=static
IPADDR=192.168.56.5
NETMASK=255.255.255.0
GATEWAY=192.168.56.1

For your information 192.168.56.1 is the ip address of host-only network card (virtual).

Then restarted network by the following command prompt code:

service network restart

Then, went to my graphical browser at host, and got the default centos-apache page. And also could browse my hosted files.

Friday, March 9, 2012

Real approach to install php/mysql on linux-apache web server

Hi, I have just found out that working on lampp in linux is not a real approach of working on PHP based software development. Recently, I need to use some multimedia encoder/decoders to compile some of my scripts, but lampp could not help me. We usually use lampp to install the whole working environment fast and in one click, but when we need some extra things to be included with this, it may not help and consume time to start.

I am using CentOS to make a real web server (for test scripts), it has a nice built in package manager YUM. I have already installed "Apache 2" for creating web server. It was easy and fast, apache (httpd) comes with centOS disks as default. I used the following line to install it.

yum install httpd

Then, I had to install php, php command line, perl, mysql to make the server ready for lamp development environment. This installation process required Internet connection and I used following line to install the whole thing.

yum install php php-cli mysql

It automatically searched all dependencies and the mirror from which they will be installed.

I didn't check the environment yet, but hope, it will help me fine.