Magic++ Draw on a TIFF image and output as a TIFF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nthaha

Magic++ Draw on a TIFF image and output as a TIFF

Post by nthaha »

Hello,

I am trying to draw text on a TIFF image and save it. But I cannot open the file on windows, I can open it using ImageMagic Display but not with anyother image viewer. See code below....

#include <Magick++.h>
#include <string>
#include <iostream>

using namespace std;
using namespace Magick;

int main( int /*argc*/, char ** argv)
{
// Initialize ImageMagick install location for Windows
InitializeMagick(*argv);

try {
Image button;

char input[] = "1775899A.tif";
button.read(input);

std::list<Magick::Drawable> drawList;
drawList.push_back(DrawablePointSize(30));
drawList.push_back(DrawableText(150, 100, "NAUSHAD THAHA"));
button.draw(drawList);

button.write("1775899A_NT.TIF");
}
catch( exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}

return 0;
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Magic++ Draw on a TIFF image and output as a TIFF

Post by magick »

The TIFF being created is fine, Windows most likely only supports a subset of the TIFF image specification. Try adding
  • button.matte(false);
    button.depth(8);
just before you write the image.
nthaha

Re: Magic++ Draw on a TIFF image and output as a TIFF

Post by nthaha »

Hello,

Thanks a lot its working now but now the image size expanded from 127KB to 469KB. I am using LWZ as my compression because with Group4 it was going up to like 600KB. Any tips to bring it back down to like 200KB would be helpfull...

Thanks again
nthaha
Post Reply