Page 1 of 1
MagickExtentImage broken on 64 bit Windows
Posted: 2011-07-21T14:00:08-07:00
by sn4p
When you set a negative offset in MagickExtentImage the resulting image becomes blank on a 64 bit OS. The same exact code on a 32 bit OS works perfectly.
Here is a code example:
Code: Select all
MagickWandGenesis();
MagickWand *wand;
wand = NewMagickWand();
MagickReadImage(wand, "C:\\1.jpg");
MagickExtentImage(wand, 800, 600, 0, -300);
MagickWriteImage(wand, "C:\\2.jpg");
wand = DestroyMagickWand(wand);
MagickWandTerminus();
My 64 bit system is:
Windows 7 64 bit
Compiler: Visual Studio 2010
ImageMagick-6.7.1-0-Q16-windows-x64-dll.exe
My 32 bit system is:
Windows Server 2008 x86
Compiler: Visual Studio 2010
ImageMagick-6.7.1-0-Q16-windows-dll.exe
Re: MagickExtentImage bug for negative offsets on 64 bit
Posted: 2011-07-21T15:13:11-07:00
by sn4p
Also, MagickExtentImage totally ignores the gravity, which is also a bug. The offsets should be taken from the gravity, not from the top left corner.
Re: MagickExtentImage bug for negative offsets on 64 bit
Posted: 2011-07-21T21:29:29-07:00
by sn4p
The MagickExtentImage is broken on 64 bit period. I did some tests and the results change randomly depending on if you do some image manipulation before or after the MagickExtentImage call. For example this code will always return a blank canvas:
Code: Select all
MagickWandGenesis();
MagickWand *wand;
wand = NewMagickWand();
MagickReadImage(wand, "c:\\1.jpg");
MagickResizeImage(wand, 150, 120, LanczosFilter, 1.0);
MagickExtentImage(wand, 150, 150, 0, 0);
MagickWriteImage(wand, "c:\\2.jpg");
DestroyMagickWand(wand);
MagickWandTerminus();
If you remove the MagickResizeImage it will work.
On 32 bit is works though.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2011-07-25T09:13:54-07:00
by sn4p
Update: I compiled IM 64 bit in VS and now it works. For some reason the pre-compiled dll:s for 64 bit was causing this error.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2011-07-25T09:35:20-07:00
by magick
Thanks for the followup. We're behind on solving some of the forum problems due to work on ImageMagick version 7 and a much needed vacation.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-02T13:08:42-07:00
by iSage
4 years later, and it's still the issue in recent pkgs on ubuntu/fedora.
Moreover, Magick++ supports gravity for extent, and, while doing the same (eg. calling ExtentImage) as MagickExtentImage produces proper image with same arguments.
Sadly, i'm writing lua binding, so doing wrapper for a wrapper in a wrapper is, well, a no-go.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-02T13:55:17-07:00
by dlemstra
I am sorry but I have no clue what you are trying to tell or ask us. But here is an attempt to answer you:
Magick++ uses 'GravityAdjustGeometry' before calling ExtentImage when the overload with gravity is called. This will recalculate the x and y of the Geometry. You will have to do the same in your wrapper if you want to force that behavior.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-02T14:54:48-07:00
by iSage
1) MagickExtentImage ignores gravity
2) passing negative offsets (which i get from 'GravityAdjustGeometry') to MagickExtentImage results in blank image
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-02T15:07:07-07:00
by dlemstra
1) Yes
2) Your image is most likely 'drawn' outside the new canvas, not sure what you are expecting.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-02T23:07:03-07:00
by iSage
2) Duh. Let's say i have 50x50 image. If i do MagickExtentImage(wand, 200,200, 10,10) image will be shifted 10px left and up (to the outside of canvas) - that works fine. If i do MagickExtentImage(wand, 200,200, -1,-1) - i'll get blank image (while, obviously, it should just shift 1px to the right and down)
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-03T02:05:33-07:00
by iSage
Erm. Okay. Calling MagickExtentImage from pure c with negative offsets works. Calling it from lua (and i've checked by adding printf with passed parameters inside MagickExtentImage) with same offsets doesn't. Not sure what happens here.
Anyway, sorry, as it seems i was wrong.
Re: MagickExtentImage broken on 64 bit Windows
Posted: 2015-03-03T03:40:24-07:00
by iSage
Nevermind. I'm stupid. Forgot to typecast values from lua ffi. Case closed