MagickExtentImage broken on 64 bit Windows

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
sn4p
Posts: 7
Joined: 2011-07-21T13:54:35-07:00
Authentication code: 8675308

MagickExtentImage broken on 64 bit Windows

Post 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
Last edited by sn4p on 2011-07-22T07:26:49-07:00, edited 2 times in total.
sn4p
Posts: 7
Joined: 2011-07-21T13:54:35-07:00
Authentication code: 8675308

Re: MagickExtentImage bug for negative offsets on 64 bit

Post 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.
sn4p
Posts: 7
Joined: 2011-07-21T13:54:35-07:00
Authentication code: 8675308

Re: MagickExtentImage bug for negative offsets on 64 bit

Post 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.
sn4p
Posts: 7
Joined: 2011-07-21T13:54:35-07:00
Authentication code: 8675308

Re: MagickExtentImage broken on 64 bit Windows

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickExtentImage broken on 64 bit Windows

Post 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.
iSage
Posts: 14
Joined: 2015-03-02T13:03:49-07:00
Authentication code: 6789

Re: MagickExtentImage broken on 64 bit Windows

Post 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.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: MagickExtentImage broken on 64 bit Windows

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
iSage
Posts: 14
Joined: 2015-03-02T13:03:49-07:00
Authentication code: 6789

Re: MagickExtentImage broken on 64 bit Windows

Post by iSage »

1) MagickExtentImage ignores gravity
2) passing negative offsets (which i get from 'GravityAdjustGeometry') to MagickExtentImage results in blank image
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: MagickExtentImage broken on 64 bit Windows

Post by dlemstra »

1) Yes
2) Your image is most likely 'drawn' outside the new canvas, not sure what you are expecting.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
iSage
Posts: 14
Joined: 2015-03-02T13:03:49-07:00
Authentication code: 6789

Re: MagickExtentImage broken on 64 bit Windows

Post 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)
iSage
Posts: 14
Joined: 2015-03-02T13:03:49-07:00
Authentication code: 6789

Re: MagickExtentImage broken on 64 bit Windows

Post 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.
iSage
Posts: 14
Joined: 2015-03-02T13:03:49-07:00
Authentication code: 6789

Re: MagickExtentImage broken on 64 bit Windows

Post by iSage »

Nevermind. I'm stupid. Forgot to typecast values from lua ffi. Case closed
Post Reply