disable antialiasig for rotation and MagickAppendImages with overlapping
disable antialiasig for rotation and MagickAppendImages with overlapping
Hi,
I have two questions
1. How can I disable antialiasing for MagickRotateImage(wand, background, degrees) ?
The image contains thin black contours more suitable for vector format. Background pixel wand is transparent. Rotation with imagemagick adds antialiasing pixels around the contours. Is it possible to have the result in exact the same colour, without any antialiasing? I understand that there will be jagged edges, it does not matter.
2. Is it possible to make MagickAppendImages do partial overlapping of the images? Preferably with configurable overlapping for each image in the sequence.
I have two questions
1. How can I disable antialiasing for MagickRotateImage(wand, background, degrees) ?
The image contains thin black contours more suitable for vector format. Background pixel wand is transparent. Rotation with imagemagick adds antialiasing pixels around the contours. Is it possible to have the result in exact the same colour, without any antialiasing? I understand that there will be jagged edges, it does not matter.
2. Is it possible to make MagickAppendImages do partial overlapping of the images? Preferably with configurable overlapping for each image in the sequence.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
1. I'm not sure exactly what you want. If you have an image that is black and white only, and rotate it, the result will also contain shades of gray.
I don't think there is any way to prevent this. Using "-distort SRT" with one of the filters such as box or point might have done this, but it doesn't seem to.
Working at a lower level, calling the functions, might offer an alternative. I don't know.
Another possibility is simply to threshold after the rotation.
2. MagickSmushImages() seems a better choice, as smush is effectively "append with positive or negative gap". See http://www.imagemagick.org/script/comma ... .php#smush and viewtopic.php?f=1&t=30720
I don't think there is any way to prevent this. Using "-distort SRT" with one of the filters such as box or point might have done this, but it doesn't seem to.
Working at a lower level, calling the functions, might offer an alternative. I don't know.
Another possibility is simply to threshold after the rotation.
2. MagickSmushImages() seems a better choice, as smush is effectively "append with positive or negative gap". See http://www.imagemagick.org/script/comma ... .php#smush and viewtopic.php?f=1&t=30720
snibgo's IM pages: im.snibgo.com
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
smush crashes on the same wand append works with without errors, with "MagickWand/magick-image.c:10542: MagickSetImageType: Assertion `wand != (MagickWand *) NULL' failed."
Code: Select all
MagickAppendImages(mw, MagickFalse); //ok
//MagickSmushImages(mw, MagickFalse, 0.0); //crash
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
What is your IM version and Platform? Perhaps you need to upgrade your IM to the current version to get smush to work? It will give partial overlap, for which append will not.
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
Linux gentoo x64, Imagemagick 7, built from github
git clone http://git.imagemagick.org/repos/ImageMagick
git clone http://git.imagemagick.org/repos/ImageMagick
Code: Select all
Version: ImageMagick 7.0.4-2 Q16 x86_64 2017-01-01 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI
Delegates (built-in): png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
So the failure is in function MagickSetImageType(). As far as I can see, MagickSmushImages() doesn't call that function. So something else in your code calls it, directly or indirectly.bayek wrote:"MagickWand/magick-image.c:10542: MagickSetImageType: Assertion `wand != (MagickWand *) NULL' failed."
Does your code correctly check for errors, or does it ignore them? Where, in your code, does the MagickSetImageType() failure occur?
snibgo's IM pages: im.snibgo.com
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
Yes you are right, smush just returns NULL, so the next line crashes.
The code looks like that:
The code looks like that:
Code: Select all
mwcombined = MagickSmushImages(mw, MagickFalse, 0.0);
MagickSetImageType(mwcombined, PaletteAlphaType);
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
also I don't understand another thing
this code is supposed to change white parts of the mwcombined to transparent, but it doesn't do this. It does something other though, as the image size gets changed, but there are no visible changes. Different values of fuzz change nothig.
http://i.cubeupload.com/F7jU0J.png - 1.png
http://i.cubeupload.com/uF8GQd.png - 2.png
both images have white line at the bottom and black/transparent above, it can be seen in gimp bettern than in browser.
MagickOpaquePaintImage
MagickOpaquePaintImage() changes any pixel that matches color with the color defined by fill.
Code: Select all
MagickSetImageType(mwcombined, GrayscaleAlphaType);
MagickWriteImage(mwcombined,"1.png");
pwwhite = NewPixelWand();
PixelSetColor(pwwhite,"white");
pwtransparent = NewPixelWand();
PixelSetColor(pwtransparent,"none");
MagickOpaquePaintImage(mwcombined, pwwhite, pwtransparent, 100, MagickFalse);
MagickWriteImage(mwcombined,"2.png");
this code is supposed to change white parts of the mwcombined to transparent, but it doesn't do this. It does something other though, as the image size gets changed, but there are no visible changes. Different values of fuzz change nothig.
http://i.cubeupload.com/F7jU0J.png - 1.png
http://i.cubeupload.com/uF8GQd.png - 2.png
both images have white line at the bottom and black/transparent above, it can be seen in gimp bettern than in browser.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
You want to change pixels to be transparent, but you are using MagickOpaquePaintImage()? Have you tried MagickTransparentPaintImage()?
snibgo's IM pages: im.snibgo.com
Re: disable antialiasig for rotation and MagickAppendImages with overlapping
MagickTransparentPaintImage changes nothing. But I found that if I use MagickTrue as the last parameter (invert) of the MagickTransparentPaintImage, it makes all the image transparent. So apparently it just does not think that color of the target matches color of the image which should be replaced. I tried both "white" and "#fefefe" (the exact lolour from colorpicker in gimp) http://i.cubeupload.com/uF8GQd.png, but it does not match the colour in any of combination of the parameters.
And I don't understand why MagickSmushImages returns NULL.
And I don't understand why MagickSmushImages returns NULL.