Hello.
Following the examples in the ImageMagick site I was able to execute this command:
convert my_img.jpg -define tiff:rows-per-strip=1 -depth 1 -background black -flatten -compress Group4 out_img.tif
it converts a jpeg image (8 bits) to tiff format (1 bit) with group 4 compression, I liked it .
Now I'm trying to do a program using MagickWand API but have no idea how to traslate these options of the command line to the program:
-define tiff:rows-per-strip=1
-background black
-flatten
-compress Group4
I used the function: MagickSetImageDepth(wand, 1) to implement the -depth 1 option and I get the output file in black and white (correctly). I tryed other functions like:
MagickSetImageCompression(wand, Group4Compression ) and MagickSetImageBackgroundColor for the other options but the image is not compressed .
Any help will be very welcome.
Kind Regards.
I have a command line that works but want it as a program
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: I have a command line that works but want it as a program
Code: Select all
// -flatten (note that this creates a new wand with the flattened image)
new_wand = MagickMergeImageLayers(wand,FlattenLayer);
// -background black
PixelWand *pw = NULL;
pw = NewPixelWand();
PixelSetColor(pw,"black");
MagickSetBackgroundColor(wand,pw);
// -compress Group4
// See also: http://www.imagemagick.org/discourse-server/viewtopic.php?f=6&t=6717
MagickSetImageCompression(wand,Group4Compression);
// -depth 1
MagickSetImageDepth(wand,1)
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: I have a command line that works but want it as a program
The equivalent of the -define command line option in the MagickWand API is MagickSetOption() and MagickSetImageOption().
Re: I have a command line that works but want it as a program
Hello el_supremo, thanks for your reply, I have added the code for:
// -background black
PixelWand *pw = NULL;
pw = NewPixelWand();
PixelSetColor(pw,"black");
MagickSetBackgroundColor(wand,pw);
// -compress Group4
// See also: viewtopic.php?f=6&t=6717
MagickSetImageCompression(wand,Group4Compression);
// -depth 1
MagickSetImageDepth(wand,1) // I had this already
It works well (don´t throw any exception) but the resulting image is not compressed (it's larger than the original). When compressed (with the command line) is it about 7k and the image I'm getting is about 88 k. I will wait to see if there is a post from Magick. I also checked the reference you tell me regardind G4 compression.
Thank you again.
// -background black
PixelWand *pw = NULL;
pw = NewPixelWand();
PixelSetColor(pw,"black");
MagickSetBackgroundColor(wand,pw);
// -compress Group4
// See also: viewtopic.php?f=6&t=6717
MagickSetImageCompression(wand,Group4Compression);
// -depth 1
MagickSetImageDepth(wand,1) // I had this already
It works well (don´t throw any exception) but the resulting image is not compressed (it's larger than the original). When compressed (with the command line) is it about 7k and the image I'm getting is about 88 k. I will wait to see if there is a post from Magick. I also checked the reference you tell me regardind G4 compression.
Thank you again.
Re: I have a command line that works but want it as a program
Thanks admin,
could you please post the example of the -define tiff:rows-per-strip=1 option using WandAPI?
Because most of the documentation and forum is about the convert command line and haven´t found some example of it.
Kind Regards.
could you please post the example of the -define tiff:rows-per-strip=1 option using WandAPI?
Because most of the documentation and forum is about the convert command line and haven´t found some example of it.
Kind Regards.
Re: I have a command line that works but want it as a program
Use MagickSetOption() or MagickSetImageOption(). For example, MagickSetOption(wand,"tiff:rows-per-strip","1");