Hi guys,
I am having a problem when uploading PDF files. I have sucessfully managed to upload one at about 20kb in size but when I try uploading a document at 500kb it isnt working and saysing 'corrupt image'. Any ideas or advice would be greatly appreciated.
Thanks,
Cargi
Problem with converting PDF to JPEG, Corrupt Image
Re: Problem with converting PDF to JPEG, Corrupt Image
The first thing you are going to be asked is "can you provide an example file" and the second thing is what "version are you using" and finaly "can you post an example of your code".
Nobody can help you without the information above.
Nobody can help you without the information above.
Re: Problem with converting PDF to JPEG, Corrupt Image
Hi there,
You can find an example at http://www.iGotMunchies.co.uk/register.php
The code I am using is as follows:
$filename = '';
$targetdir = 'uploads/menus/';
include('imagemagick_class.php');
$imObj = new ImageMagick($_FILES['image1']);
$imObj -> setVerbose(TRUE);
$imObj -> setTargetdir($targetdir);
$imObj -> Convert(jpg);
$filename = $imObj -> Save();
$imObj -> CleanUp();
$imObj2 = new ImageMagick($_FILES['image2']);
$imObj2 -> setVerbose(TRUE);
$imObj2 -> setTargetdir($targetdir);
$imObj2 -> Convert(jpg);
$filename2 = $imObj2 -> Save();
$imObj2 -> CleanUp();
Thanks
You can find an example at http://www.iGotMunchies.co.uk/register.php
The code I am using is as follows:
$filename = '';
$targetdir = 'uploads/menus/';
include('imagemagick_class.php');
$imObj = new ImageMagick($_FILES['image1']);
$imObj -> setVerbose(TRUE);
$imObj -> setTargetdir($targetdir);
$imObj -> Convert(jpg);
$filename = $imObj -> Save();
$imObj -> CleanUp();
$imObj2 = new ImageMagick($_FILES['image2']);
$imObj2 -> setVerbose(TRUE);
$imObj2 -> setTargetdir($targetdir);
$imObj2 -> Convert(jpg);
$filename2 = $imObj2 -> Save();
$imObj2 -> CleanUp();
Thanks
Re: Problem with converting PDF to JPEG, Corrupt Image
We need a copy of the pdf file.
Re: Problem with converting PDF to JPEG, Corrupt Image
Works Ok for me using:
I do not know what size you want but this will give a better quality image:
IM version 6.4.0 04/16/08 Q16
Code: Select all
<?php
exec("convert sample.pdf sample.jpg");
?>
Code: Select all
<?php
exec("convert -density 300 sample.pdf -resize 50% sample.jpg");
?>
Re: Problem with converting PDF to JPEG, Corrupt Image
Hi Bronzo,
Thanks for the help, one i should of said earlier is that I am using the imagemagick_class file. This looks to be what would normally be
exec("convert sample.pdf sample.jpg");
I quess it is a problem within the imagemagick_class file then.
$command = "{$this->imagemagickdir}/convert -colorspace RGB -quality {$this->jpg_quality} '{$this->temp_dir}/tmp{$this->count}_{$this->temp_file}' '{$this->temp_dir}/tmp".++$this->count."_{$name}'";
The class file can be found at http://www.bokko.nl/projects/php-imagemagick-class
Thanks for the help, one i should of said earlier is that I am using the imagemagick_class file. This looks to be what would normally be
exec("convert sample.pdf sample.jpg");
I quess it is a problem within the imagemagick_class file then.
$command = "{$this->imagemagickdir}/convert -colorspace RGB -quality {$this->jpg_quality} '{$this->temp_dir}/tmp{$this->count}_{$this->temp_file}' '{$this->temp_dir}/tmp".++$this->count."_{$name}'";
The class file can be found at http://www.bokko.nl/projects/php-imagemagick-class
Re: Problem with converting PDF to JPEG, Corrupt Image
I did notice you were using a class and I have quickly tried it but I get "Imagemagick: Upload failed"; I am not that interested in finding how it works at the moment and so will not look at it any further.
If the code I posted works then it must be the class if not there must be a problem with the IM or Ghostscript install.
The class looks a bit OTT if all you want to do is upload and resize an image, this is an example of a form to do the same thing I wrote a few years ago: http://www.rubblewebs.co.uk/imagemagick/codes/thumb.php
If the code I posted works then it must be the class if not there must be a problem with the IM or Ghostscript install.
The class looks a bit OTT if all you want to do is upload and resize an image, this is an example of a form to do the same thing I wrote a few years ago: http://www.rubblewebs.co.uk/imagemagick/codes/thumb.php
Re: Problem with converting PDF to JPEG, Corrupt Image
man how much would you charge to develop this for me because i can't see where i am going soo wrong