How to use blob in codeigniter?

Posted by

I’m new to PHP. How I can use blob in CodeIgniter? What is the best option for sending an image from the server to a client (RESTful) using codeigniter? I have tried the following:

$newPerson = new Person();
$newPerson->id = 1;
$newPerson->firstName = "Qutfullo";
$newPerson->lastName = "Ochilov";
$image=new Imagick();
$image->setImage("my.jpg");
$newPerson->image=$image->getImageBlob();
$this->response($newPerson);

But I get an exception:

Fatal error: Class ‘Imagick’ not found.

ou would use it the same way as you would without CodeIgniter. Are you working with some code that doesn’t work? It would be helpful to see that code, otherwise this question is just far too broad for this site. – MonkeyZeus

this is error not exception? try to include Class ‘Imagick’ might be missing in php libraray – Abhishek

Answer 1

Hope below snippet can give you the idea that you are missing library —

Try below code if on ubuntu —

php -m | grep imagick.

If the result is empty then issue below commands from terminal

sudo apt-get remove --purge php5-imagick && sudo apt-get install php5-imagick

if on window sserver follow below link instructions that might be useful

Install Imagick for PHP and Apache on Windows

Answer 2

The error is because of your server have no Image Magic Software suite. First you install it in your server.

For install Image Magic in Unix/Linux

Download ImageMagick.tar.gz from www.imagemagick.org

Unpack the distribution with this command:

tar xvzf ImageMagick.tar.gz

Next configure and compile ImageMagick:

cd ImageMagick-6.9.3
 ./configure
 make

To install, type

sudo make install

You may need to configure the dynamic linker run-time bindings:

sudo ldconfig /usr/local/lib

Install from Windows Source

Download ImageMagick-windows.zip from www.imagemagick.org

Unzip and Install

unzip ImageMagick-windows.zip

Please refer this link for installation.

More Post Like This :- PHP Display Errors

Leave a Reply

Your email address will not be published. Required fields are marked *