Image cut in half when converting PDF to PNG with -resize
Posted: 2011-06-06T14:01:21-07:00
I am using image magick with C# to convert a pdf with an upload tool I built. Works amazing for all pdfs until today.
A user uploaded a pdf and it converts & resizes, but cuts it in half!
Has anyone else heard of this?
Here is my code:
A user uploaded a pdf and it converts & resizes, but cuts it in half!
Has anyone else heard of this?
Here is my code:
Code: Select all
//restrict image size to 200 pixels
string newSize = "200x200 ";
string opt = " -resize " + newSize;
// setup a process to run the ImageMagick converter
pdfToPngProcess.StartInfo.UseShellExecute = false;
pdfToPngProcess.StartInfo.CreateNoWindow = true;
pdfToPngProcess.StartInfo.RedirectStandardError = true;
pdfToPngProcess.StartInfo.RedirectStandardOutput = true;
pdfToPngProcess.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + @"\Scripts\ImageMagick\convert.exe";
// quote filenames so we don't have to worry about spaces in file paths
pdfToPngProcess.StartInfo.Arguments = string.Format(@"""{0}"" {1} ""{2}""", sourcePDFPath, opt, destinationFullPath);
//// attempt to convert the images and wait until it completes
pdfToPngProcess.Start();
pdfToPngProcess.WaitForExit();