imagemagick'a modulateimage and windows7 problem

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
poplintwist
Posts: 3
Joined: 2011-03-29T06:29:35-07:00
Authentication code: 8675308

imagemagick'a modulateimage and windows7 problem

Post by poplintwist »

Hi,
I'm working on image editing application using GTK+ and imagemagick. Everything was fine when I was running my app on Linux or win XP, but when I run it on win7 something strange happens. MagickCore's modulateImage method adds horizontal lines to the image. Example image:
Image

turns into:
Image

Here is minimal working code:

Code: Select all

#include <gtk/gtk.h>
#include <iostream>
#include <wand/MagickWand.h>

int main( int argc, char *argv[])
{
  gtk_init(&argc, &argv);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_resizable(GTK_WINDOW(window), FALSE);

    GError* error=NULL;
    GdkPixbuf* _pixbuf = gdk_pixbuf_new_from_file("gps-photolinkfountain2.jpg",&error);
    if (error != NULL) exit(1);

    Image *magickImage;
    ExceptionInfo ex;
    GetExceptionInfo(&ex);

    guchar* _pixels = gdk_pixbuf_get_pixels(_pixbuf);
    int _w = gdk_pixbuf_get_width(_pixbuf);
    int _h = gdk_pixbuf_get_height(_pixbuf);

    magickImage = ConstituteImage(_w,_h,"RGB",CharPixel,_pixels,&ex);

    if (ex.severity != UndefinedException) CatchException(&ex);
    if (magickImage == (Image *) NULL) exit(1);

//!Modulate makes unexpected effect
    ModulateImage(magickImage,"100,100,100");
//!SigmoidalContrast works fine
//    SigmoidalContrastImage(magickImage,(MagickBooleanType)true,"40");

    ExportImagePixels( magickImage, 0, 0, _w, _h, "RGB", CharPixel, _pixels, &ex );
    if(ex.severity != UndefinedException) CatchException(&ex);

  GtkWidget *image = gtk_image_new_from_pixbuf (_pixbuf);
  gtk_container_add(GTK_CONTAINER(window), image);

  g_signal_connect_swapped(G_OBJECT(window), "destroy",
        G_CALLBACK(gtk_main_quit), G_OBJECT(window));

  gtk_widget_show_all(window);
  gtk_main();
}

Strange thing is that other methods like SigmoidalContrastImage work fine.
It does not matter if I compile my application on winXP and migrate executable file to win7 or compile it on win7.

My System:
  • Windows 7 Professional 32-bit
  • Intel Atom N450
My Development toolkit:
  • GTK+2.2 - I have tried other versions.
  • Code::Blocks 10.05 with integrated MinGW
An the question is:
Am I doing something wrong (and maybe how to fix it) or is it a Imagemagick's or win7 bug?

Best regards
Sebastian
Last edited by poplintwist on 2011-03-30T09:01:17-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: imagemagick'a modulateimage and windows7 problem

Post by magick »

Let's see if its an OpenMP problem under Windows 7. Add
  • MagickCoreGenesis(*argv,MagickTrue);
    SetMagickResourceLimit(ThreadResource,1);
Before the call to ConstituteImage(); Does that fix the problem?
poplintwist
Posts: 3
Joined: 2011-03-29T06:29:35-07:00
Authentication code: 8675308

Re: imagemagick'a modulateimage and windows7 problem

Post by poplintwist »

Thanks for fast reply.
Effect of adding this code:

Code: Select all

    MagickCoreGenesis(*argv,MagickTrue);
    SetMagickResourceLimit(ThreadResource,1);
is:

Image

Now image has got one big red stripe, when function

Code: Select all

    ModulateImage(magickImage,"100,100,100");
should not change anything, so this problem is still open.

Sebastian
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: imagemagick'a modulateimage and windows7 problem

Post by magick »

It points to a problem with OpenMP under Win 7. Does -modulate work properly from the command line (e.g. convert myimage -modulate ...)? Also try another image other than gps-photolinkfountain2.jpg. Does the problem still occur?

Next, add WriteImage() and write the image to gps-photolinkfountain2.png and display that with a Windows application to ensure GTK is not corrupting the image.
poplintwist
Posts: 3
Joined: 2011-03-29T06:29:35-07:00
Authentication code: 8675308

Re: imagemagick'a modulateimage and windows7 problem

Post by poplintwist »

Does -modulate work properly from the command line (e.g. convert myimage -modulate ...)?
From command line IM works properly.
Also try another image other than gps-photolinkfountain2.jpg. Does the problem still occur?
Problem still occurs.
add WriteImage() and write the image to gps-photolinkfountain2.png and display that with a Windows application to ensure GTK is not corrupting the image.
WriteImage() writes the same image that we can see in GTK window (with "red effect").

Sebastian
pbarczyn
Posts: 1
Joined: 2011-04-05T00:24:14-07:00
Authentication code: 8675308

Re: imagemagick'a modulateimage and windows7 problem

Post by pbarczyn »

I have the same problem.

Does anyone have any solution for this?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: imagemagick'a modulateimage and windows7 problem

Post by el_supremo »

FYI: I compiled and ran this code and it works fine:

Code: Select all

#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(void)
{
	MagickWand *mw = NULL;
	MagickWandGenesis();

	mw = NewMagickWand();
	MagickReadImage(mw,"fountain.jpg");
	MagickModulateImage(mw,100,100,100);
	MagickWriteImage(mw,"fountain_mod.jpg");

	if(mw)mw = DestroyMagickWand(mw);
	MagickWandTerminus();
}
This is using IM 6.6.8-6 2011-03-21 Q16 OPENMP on Win7 Pro 64-bit i7-970 and 24GB of ram.

@poplintwist: Can you try the above code?

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.
tom
Posts: 1
Joined: 2013-04-25T15:26:34-07:00
Authentication code: 6789

Re: imagemagick'a modulateimage and windows7 problem

Post by tom »

Hello,

I know this is an old thread but I've just come across exactly the same problem - when calling MagickModulateImage, the image gets distorted by the horizontal red stripes. Convert -modulate works fine.

I've already tested a few different versions, but the problem appears on each of them (haven't tried all of them though)...

EDIT: In my case this happens on WinXP!

Thanks in advance for your advice,
Tom
Post Reply