Page 1 of 3

Odd issues when compiling on windows

Posted: 2007-10-04T10:03:11-07:00
by mkoppanen
I'm using the MagickWand API in the Imagick -project. The problem is that when I compile Imagick statically against ImageMagick libraries the PNG transparency does not work.

This happens on Windows and with all versions of ImageMagick (including 6.3.6) I have tested and with Q8 and Q16. I'm totally out of ideas why this might happen.

Re: Odd issues when compiling on windows

Posted: 2007-10-04T11:50:07-07:00
by mkoppanen
With the static build im able to achieve whole image transparency with adding this method call:

$im->setImageOpacity( 0 );

Without that the image created with newimage and PixelWand transparent is shown black.

Re: Odd issues when compiling on windows

Posted: 2007-10-04T22:50:45-07:00
by mkoppanen
I downloaded this compile of the MagickWand PHP extension:

http://www.dirk.sh/dirk/magickwand/

(The static compile).

And tested it with this code:

Code: Select all

<?php

$m = NewMagickWand();
$p = NewPixelWand();

PixelSetColor( $p, "transparent" );

MagickNewImage( $m, 100, 100, $p );

MagickSetImageFormat( $m, "png" );

MagickWriteImage( $m, "trans_magick.png" );
?>
This results also into a black image.

Re: Odd issues when compiling on windows

Posted: 2007-10-05T08:19:44-07:00
by el_supremo
Hi Mikko,
I tried a C version of your code and it produces a transparent PNG.
The problem might be with the viewer you are using. Does it display transparency in a way that
shows up, such as the checkerboard pattern that Paint Shop Pro uses?
Instead of "transparent" try this "rgba(255,0,0,0.0)". If your viewer shows this
as a red square then it's not handling transparency properly.

Pete

Re: Odd issues when compiling on windows

Posted: 2007-10-05T08:26:12-07:00
by mkoppanen
el_supremo wrote:Hi Mikko,
I tried a C version of your code and it produces a transparent PNG.
The problem might be with the viewer you are using. Does it display transparency in a way that
shows up, such as the checkerboard pattern that Paint Shop Pro uses?
Instead of "transparent" try this "rgba(255,0,0,0.0)". If your viewer shows this
as a red square then it's not handling transparency properly.

Pete
The viewers I tested are: Windows Image Viewer (the built in one), firefox and Gimp.

Here is a link to the generated image: Image

Re: Odd issues when compiling on windows

Posted: 2007-10-05T08:28:11-07:00
by mkoppanen
And here is the identify -verbose output:

Code: Select all

mikko@todellisuus:~/public_html$ identify -verbose trans_win.png
Image: trans_win.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 200x200+0+0
  Type: PaletteMatte
  Endianess: Undefined
  Colorspace: RGB
  Depth: 1-bit
  Channel depth:
    Red: 1-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Red:
      Min: 1 (1)
      Max: 1 (1)
      Mean: 1 (1)
      Standard deviation: 0 (0)
    Green:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
    Blue:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
    Opacity:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
  Histogram:
     40000: (255,  0,  0,  0) #FF0000 red
  Rendering intent: Undefined
  Resolution: 72x72
  Units: Undefined
  Filesize: 628b
  Interlace: None
  Background color: rgb(1,1,1)
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: none
  Page geometry: 200x200+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Signature: d6550ab15fc613b897a575c3bac1f09fb6c9ebe160312438709f18a8f693b55e
  Tainted: False
  Version: ImageMagick 6.3.6 10/02/07 Q16 http://www.imagemagick.org
Here is the identify output using exactly the same code in linux:

Code: Select all

mikko@todellisuus:~/public_html$ identify -verbose trans_lin.png
Image: trans_lin.png
  Format: PNG (Portable Network Graphics)
  Class: DirectClass
  Geometry: 200x200+0+0
  Type: PaletteMatte
  Endianess: Undefined
  Colorspace: RGB
  Depth: 1-bit
  Channel depth:
    Red: 1-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Red:
      Min: 1 (1)
      Max: 1 (1)
      Mean: 1 (1)
      Standard deviation: 0 (0)
    Green:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
    Blue:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
    Opacity:
      Min: 1 (1)
      Max: 1 (1)
      Mean: 1 (1)
      Standard deviation: 0 (0)
  Alpha: rgba(255,0,0,1)    #FFFF000000000000
  Histogram:
     40000: (65535,    0,    0,65535) #FFFF000000000000 rgba(255,0,0,1)
  Rendering intent: Undefined
  Resolution: 72x72
  Units: Undefined
  Filesize: 826b
  Interlace: None
  Background color: white
  Border color: rgb(223,223,223)
  Matte color: grey74
  Transparent color: none
  Page geometry: 200x200+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Signature: 780ab2cbd31b6ca6ef808f07ea25d432e7d097649df51b6fc1f97ef17f917e25
  Tainted: False
  Version: ImageMagick 6.3.6 10/02/07 Q16 http://www.imagemagick.org

Re: Odd issues when compiling on windows

Posted: 2007-10-05T16:15:24-07:00
by mkoppanen
I assume something that is initialized with DLLs is not intialized in static compile.

Pete, did you compile your C code with static or dynamic linking?

Re: Odd issues when compiling on windows

Posted: 2007-10-05T16:23:46-07:00
by el_supremo
It uses 6.3.5 Q8 dynamic linking.

Pete

Re: Odd issues when compiling on windows

Posted: 2007-10-05T16:26:53-07:00
by mkoppanen
I was only able to get this issue with static linking. If I link dynamically everything works.

Re: Odd issues when compiling on windows

Posted: 2007-10-11T10:38:34-07:00
by mkoppanen
Pete,

if you have time some day could you try this issue with static compile?

Re: Odd issues when compiling on windows

Posted: 2007-10-12T08:36:48-07:00
by el_supremo
Mikko,
I'll try to do that on the weekend.
Meanwhile, it has struck me as odd that identify prints different formats for the histogram.
The first was printed as:
40000: (255, 0, 0, 0) #FF0000 red
and the second was:
40000: (65535, 0, 0,65535) #FFFF000000000000 rgba(255,0,0,1)
The first suggests that it is being printed by a Q8 version of IM whereas the second is Q16. Do you have a Q8 version of IM on your system that might be being linked in when doing a static link?

Pete

Re: Odd issues when compiling on windows

Posted: 2007-10-22T04:33:20-07:00
by mkoppanen
el_supremo wrote:Mikko,
I'll try to do that on the weekend.
Meanwhile, it has struck me as odd that identify prints different formats for the histogram.
The first was printed as:
40000: (255, 0, 0, 0) #FF0000 red
and the second was:
40000: (65535, 0, 0,65535) #FFFF000000000000 rgba(255,0,0,1)
The first suggests that it is being printed by a Q8 version of IM whereas the second is Q16. Do you have a Q8 version of IM on your system that might be being linked in when doing a static link?

Pete
Pete, you are correct that the first one was with Q8. But Q16 produces similar results:

Code: Select all

Image:
 Format: png (Portable Network Graphics)
- Hide quoted text -
 Class: DirectClass
 Geometry: 100x100+0+0
 Type: Bilevel
 Endianess: Undefined
 Colorspace: Gray
 Channel depth:
   Gray: 1-bit
 Channel statistics:
   Gray:
     Min: 0 (0)
     Max: 0 (0)
     Mean: 0 (0)
     Standard deviation: 0 (0)
 Colors: 1
 Histogram:
    10000: #000000000000 none
 Rendering intent: Undefined
 Resolution: 72x72
 Units: Undefined
 Filesize: 0b
 Interlace: None
 Background color: white
 Border color: rgb(223,223,223)
 Matte color: gray74
 Transparent color: none
 Dispose: Undefined
 Iterations: 0
 Compression: Undefined
 Orientation: Undefined
 Signature: 9a413b131ecf0ccfb02a837ddb33766d8604cc00da7937b79bd363b53c8d7d86
 Tainted: True
 User time: 0.010u
 Elapsed time: 0:01
 Pixels per second: 195.307kb
 Version: ImageMagick 6.3.3 04/21/07 Q16 http://www.imagemagick.org
It is a same set of API calls as in the previous examples.

The imagick code to create this one:

Code: Select all

<?php
$im = new Imagick();

$im->newImage( 100, 100, new ImagickPixel( "transparent" ) );
$im->setImageFormat( "png" );

$id = $im->identifyImage( true );


echo "<pre>";
var_dump( $id['rawOutput'] );
?>
Those calls map directly to the api calls.

Re: Odd issues when compiling on windows

Posted: 2007-12-01T19:37:55-07:00
by el_supremo
Hi Mikko,
Sorry, I forgot all about trying a static compile for you.
It's probably too late to help you now but I just recompiled my test code statically and it produces a transparent image.

Pete

Re: Odd issues when compiling on windows

Posted: 2007-12-02T05:39:58-07:00
by mkoppanen
el_supremo,

Good to hear! I'll do some tests today!

Re: Odd issues when compiling on windows

Posted: 2007-12-02T12:35:52-07:00
by mkoppanen
I still don't get it right.

Here is the Visual Studio project: http://valokuva.org/outside-blog-conten ... agickTest/

Here is the generated image: Image


I don't really see what I am doing wrong here. The image is shown as black in just about any viewer I try.