Completed

Fix PHP code to convert PDF file to PNG file

This project was successfully completed by powertech for $64 USD in a day.

Get free quotes for a project like this
Employer working
Project Budget
$30 - $250 USD
Completed In
1 day
Total Bids
13
Project Description

Below you can see our the PHP code we use to convert one PDF file to one multipage PNG file. The library that is referenced can be found here (I think): [url removed, login to view]

Our problem is that we run on an EC2-micro instance with 600 mb of ram and on some files the resolution of the resulting PNG file is too low to be readable. If we increase the resolution parameters from 100 to 400 below, then it the process will often crash. I need someone who can fix this problem, either by fixing the code below or finding a different library to achieve the same thing. You will get access to our linux server.

<?php

$img_temp = $_POST['img_temp'];

$file_path = $_POST["file_path"];

$file_type = strtoupper(substr(strrchr($file_path, "."), 1));

$im = new Imagick();

$im->setresourcelimit(imagick::RESOURCETYPE_MEMORY, 32);

$im->setresourcelimit(imagick::RESOURCETYPE_MAP, 32);

$im->setFormat($file_type);

$im->readImage($file_path);

$count = 1;

$num_image = $im->getNumberImages();

//convert each page

for ($x = 1;$x <= $num_image; $x++)

{

$im->destroy();

$im->setResolution(100, 100);

$im->setFormat($file_type);

$im->readImage($file_path . "[" . ($x-1) . "]");

$im->writeImage($img_temp . '/img[' . $count . '].png');

$count++;

}

echo "conversion successful";

?>

Completed by:

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online