I'm new to ImageMagick and have no idea what I'm doing. My hosting company
has told me ImageMagick and GhostScript are installed on my server. All I'm
trying to do is convert a PDF to JPEG. After looking through some of the
threads on this forum, I've come to the conclusion that it's not that
difficult, but it doesn't seem to be working for me. Here's the code I'm
using:
function cmyk2rgb($file) {
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $file);
$img_colspc = MagickGetImageColorspace($mgck_wnd);
if ($img_colspc == MW_CMYKColorspace) {
echo "$file was in CMYK format";
MagickSetImageColorspace($mgck_wnd,
MW_RGBColorspace);
}
}
if($ext == "pdf"){
$origfile = $_FILES['upload']['name'];
$origfile = "files/".$orgdir."/".$origfile;
$newfile = "new_".$_FILES['upload']['name'];
$newfile = "files/".$orgdir."/".$newfile;
// convert file
exec("convert $origfile $newfile");
cmyk2rgb($newfile);
}
What i've looked at all my variables and they all look right. But when i
check the directory, the new file isn't there. I'm not getting any errors
either. What is wrong?
I also need a similar method of doing Tif to Jpeg. Haven't tried it yet,
but doubt it will work. Am I missing something?
function tiff2jpg($file) {
$mgck_wnd = NewMagickWand();
MagickReadImage($mgck_wnd, $file);
$img_colspc = MagickGetImageColorspace($mgck_wnd);
if ($img_colspc == MW_CMYKColorspace) {
echo "$file was in CMYK format";
MagickSetImageColorspace($mgck_wnd,
MW_RGBColorspace);
}
MagickSetImageFormat($mgck_wnd, 'JPG' );
MagickWriteImage($mgck_wnd, str_replace('.tif', '.jpg',
$file));
}
if($ext == "tif" || $ext == "tiff"){
//copy file to new name
$origfile = $_FILES['upload']['name'];
$origfile = "files/".$orgdir."/".$origfile;
$newfile = "new_".$_FILES['upload']['name'];
$newfile = "files/".$orgdir."/".$newfile;
if (!copy($origfile, $newfile)) {
$filecopyerror = "true";
}
// convert file
cmyk2rgb($newfile);
tiff2jpg($newfile);
}
--
View this message in context:
http://www.nabble.com/Converting-PDF-to-JPEG-for-preview-t1351218.html#a3616009
Sent from the Magick-users forum at Nabble.com.
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users