Here we will see how to convert pdf to image in laravel. We will convert Pdf To Image using imagick package. You can easily convert pdf to image any format in laravel. If you want to convert pdf to image than you can use the example given below.

Given below is the full example for pdf to image convert in laravel as below. Follow this step by step process to convert PDF to image

Step 1: Installing Imagick PHP Extension And Configuration

We will install the Imagick PHP extension is available from the Ubuntu’s repositories. Like ImageMagick, to do an imagick php install we can simply run the apt install command.

sudo apt install php-imagick

If you require a previous version of php-imagick, you can list the version available from the Ubuntu repositories using the apt list command.

sudo apt list php-magick -a

The -a flag tells apt to list all version of a package available from the repositories. The output will look similar to the following, and at the time of this writing, there was only a single version available.

php-imagick/bionic,now 3.4.3~rc2-2ubuntu4 amd64 [installed]

restart apache web server

Installing the module alone isn’t enough. In order for any new PHP extension to be used with your web application Apache must be restarted.

sudo systemctl restart apache2

Verify Installation

To verify the installation was successful and that the module is enabled properly, we can use php -m from the command line, and grep the results to limit the output to only the line that is important.

Run the following command to verify the installation.

 php -m | grep imagick

If the installation was successful, the output of the command will simply show one line, and it will only contain the name of the module imagick.


For a much more detailed verification of whether the PHP module was installed correctly, use the phpinfo() method.

From the command line, run the following command

php -r 'phpinfo();' | grep imagick

Which will display the following information, where the modules status is shown as enabled.

imagick module => enabled
imagick module version => 3.4.4
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 1 => 1

Step 2: Create Route

Now, we need to add resource route for pdf to image convert in laravel application. So open your "routes/web.php" file and add following route.


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\FromController;

Route::get('form', [FromController::class, 'index'])->name('form');

Step 3: Create Controller

Now we should create new controller as FromController, so run below command to generate new controller

php artisan make:controller FromController

At last we need to update FromController.php.


namespace App\Http\Controllers;

use Imagick;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Blade;

class FromController extends Controller
     * Write code on Method
     * @return response()
    public function index()
        $imagick = new Imagick();


        $imagick->writeImages('converted.jpg', true);


Now we are ready to run our custom validation rules example so run the command below for quick run:

php artisan serve

Now you can open the URL below on your browser:


I hope this example helps you