Readimage low resolution C++

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Jessica Wu
Posts: 1
Joined: 2013-05-17T00:55:13-07:00
Authentication code: 6789

Readimage low resolution C++

Post by Jessica Wu » 2013-05-17T01:21:38-07:00

I use the imagemagick++ API in my C++ programm. Readimage is used to read a multi-pages PDF file. But the resolution of the output image is too low.

vector<Image> imageList;
readImages( &imageList, "E:/ww.pdf" );
for(int i = 0; i < imageList.size(); i++)
{imageList.density("300");}
writeImages( imageList.begin(), imageList.end(), "D:/yes.tif" );

Is there some solutions to improve the resolution.

User avatar
dlemstra
Posts: 1587
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Readimage low resolution C++

Post by dlemstra » 2013-05-17T15:56:49-07:00

You need to assign the density before reading the image. You cannot do that with readImages right now. But if you inline the content of readImages it can be done:

Code: Select all

// Not tested:
MagickCore::ImageInfo *imageInfo = MagickCore::CloneImageInfo(0);

std::string imageSpec =  "E:/ww.pdf";
imageSpec.copy(imageInfo->filename, MaxTextExtent-1);
imageInfo->filename[imageSpec.length()] = 0;
MagickCore::CloneString(&imageInfo->density, "300");

MagickCore::ExceptionInfo exceptionInfo;
MagickCore::GetExceptionInfo(&exceptionInfo);
MagickCore::Image* images = MagickCore::ReadImage(imageInfo, &exceptionInfo);
MagickCore::DestroyImageInfo(imageInfo);
Magick::insertImages(imageList, images);
Magick::throwException(exceptionInfo);
MagickCore::DestroyExceptionInfo(&exceptionInfo);
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply