DefineValue("tiff", "alpha", "associated"); not working

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
luis.armengol
Posts: 6
Joined: 2012-07-09T05:02:07-07:00
Authentication code: 13

DefineValue("tiff", "alpha", "associated"); not working

Post by luis.armengol »

Hi,

Im trying to save a TIFF from Magick++ with associated alpha extrasamples. I can do it perfectly through convert command-line and -define tiff:alpha=associated but from Magick++ interface is not working. I have tried also to use "TIFF" as format without any luck.

I have noticed that the image saved from convert command has a mixed Deph: 8/16 Bits using the define clausure.

Im using ImageMagick 6.6.9-3 2011-04-06 Q16.

Any clue?

Thanks in advance
L
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DefineValue("tiff", "alpha", "associated"); not working

Post by magick »

Try defineValue() with parameters "tiff:alpha" and "associated" before you write the image.
luis.armengol
Posts: 6
Joined: 2012-07-09T05:02:07-07:00
Authentication code: 13

Re: DefineValue("tiff", "alpha", "associated"); not working

Post by luis.armengol »

Thanks for your quick answer.

There is no luck. I have tried with:

- finalImage.defineValue("tiff:alpha", "associated");
- finalImage.defineValue("", "tiff:alpha", "associated");
- finalImage.defineValue("tiff", "tiff:alpha", "associated");


This is the code Im executing when writting the image after some composite calls with CopyCompositeOp:

Code: Select all

finalImage.compressType(LZWCompression);
finalImage.defineValue("tiff:alpha", "associated");
finalImage.write(tempFileName);


///////////////////////////////////
// SAVED WITH MAGICK++
///////////////////////////////////

[root@pegaso img]# tiffinfo bgr_tst0010_scn0001.0101.tif
TIFF Directory at offset 0x2abd8 (175064)
Image Width: 500 Image Length: 500
Resolution: 72, 72 (unitless)
Bits/Sample: 8
Compression Scheme: LZW
Photometric Interpretation: RGB color
Extra Samples: 1<unassoc-alpha>
FillOrder: lsb-to-msb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 4
Rows/Strip: 4
Planar Configuration: single image plane
Page Number: 0-1
DocumentName: /tmp/bgr_tst0010_scn0001.0101.tif
Predictor: horizontal differencing 2 (0x2)


[root@pegaso img]# identify -verbose bgr_tst0010_scn0001.0101.tif
Image: bgr_tst0010_scn0001.0101.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 500x500+0+0
Resolution: 72x72
Print size: 6.94444x6.94444
Units: Undefined
Type: TrueColorMatte
Base type: TrueColor
Endianess: LSB
Colorspace: RGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 202 (0.792157)
mean: 20.1385 (0.0789746)
standard deviation: 45.4869 (0.17838)
kurtosis: 2.48223
skewness: 2.00216
Green:
min: 0 (0)
max: 165 (0.647059)
mean: 12.2329 (0.0479723)
standard deviation: 29.0318 (0.11385)
kurtosis: 4.95114
skewness: 2.39517
Blue:
min: 0 (0)
max: 136 (0.533333)
mean: 4.35831 (0.0170914)
standard deviation: 13.9834 (0.054837)
kurtosis: 29.2704
skewness: 4.9797
Alpha:
min: 0 (0)
max: 255 (1)
mean: 47.1342 (0.18484)
standard deviation: 95.2149 (0.373392)
kurtosis: 0.89726
skewness: -1.68605
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 61.1489 (0.2398)
standard deviation: 55.1664 (0.216339)
kurtosis: 27.7998
skewness: 7.7031
Alpha: none #00000000
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Compose: Over
Page geometry: 500x500+0+0
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Properties:
date:create: 2013-03-08T13:58:15+01:00
date:modify: 2013-03-08T13:58:15+01:00
signature: c8cf4265021a99e0bcc61fa45a68494344da0bd26ec974b6a67577f1f09152f5
tiff:alpha: unassociated
tiff:document: /tmp/bgr_tst0010_scn0001.0101.tif
tiff:endian: lsb
tiff:photometric: RGB
tiff:rows-per-strip: 4
Artifacts:
verbose: true
Tainted: False
Filesize: 176KBB
Number pixels: 250KB
Pixels per second: 12.5MB
User time: 0.020u
Elapsed time: 0:01.020
Version: ImageMagick 6.6.9-3 2011-04-06 Q16 http://www.imagemagick.org


//////////////////////////////////////////////////////
// RESAVED WITH CONVERT -define tiff:alpha=associated
// (convert -define tiff:alpha=associated bgr_tst0010_scn0001.0101.tif bgr_tst0010_scn0001.0101.tif)
//////////////////////////////////////////////////////

[root@pegaso img]# tiffinfo bgr_tst0010_scn0001.0101.tif
TIFF Directory at offset 0x2aa06 (174598)
Image Width: 500 Image Length: 500
Resolution: 72, 72 (unitless)
Bits/Sample: 8
Compression Scheme: LZW
Photometric Interpretation: RGB color
Extra Samples: 1<assoc-alpha>
FillOrder: lsb-to-msb
Orientation: row 0 top, col 0 lhs
Samples/Pixel: 4
Rows/Strip: 4
Planar Configuration: single image plane
Page Number: 0-1
DocumentName: bgr_tst0010_scn0001.0101.tif
Predictor: horizontal differencing 2 (0x2)


[root@pegaso img]# identify -verbose bgr_tst0010_scn0001.0101.tif
Image: bgr_tst0010_scn0001.0101.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 500x500+0+0
Resolution: 72x72
Print size: 6.94444x6.94444
Units: Undefined
Type: TrueColorMatte
Base type: TrueColor
Endianess: LSB
Colorspace: RGB
Depth: 8/16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 202 (0.792157)
mean: 20.1478 (0.0790109)
standard deviation: 45.491 (0.178396)
kurtosis: 2.46593
skewness: 1.99929
Green:
min: 0 (0)
max: 165 (0.64567)
mean: 12.253 (0.048051)
standard deviation: 29.0735 (0.114014)
kurtosis: 4.93188
skewness: 2.39282
Blue:
min: 0 (0)
max: 136 (0.531502)
mean: 4.36667 (0.0171242)
standard deviation: 14.0082 (0.054934)
kurtosis: 29.2376
skewness: 4.97771
Alpha:
min: 0 (0)
max: 255 (1)
mean: 47.1342 (0.18484)
standard deviation: 95.2149 (0.373392)
kurtosis: 0.89726
skewness: -1.68605
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 61.1583 (0.239837)
standard deviation: 55.1743 (0.21637)
kurtosis: 27.7761
skewness: 7.69792
Alpha: none #00000000
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Compose: Over
Page geometry: 500x500+0+0
Dispose: Undefined
Iterations: 0
Compression: LZW
Orientation: TopLeft
Properties:
date:create: 2013-03-08T14:04:10+01:00
date:modify: 2013-03-08T14:04:10+01:00
signature: c8cf4265021a99e0bcc61fa45a68494344da0bd26ec974b6a67577f1f09152f5
tiff:alpha: unassociated
tiff:document: bgr_tst0010_scn0001.0101.tif
tiff:endian: lsb
tiff:photometric: RGB
tiff:rows-per-strip: 4
Artifacts:
verbose: true
Tainted: False
Filesize: 176KBB
Number pixels: 250KB
Pixels per second: 8.333MB
User time: 0.020u
Elapsed time: 0:01.030
Version: ImageMagick 6.6.9-3 2011-04-06 Q16 http://www.imagemagick.org
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: DefineValue("tiff", "alpha", "associated"); not working

Post by magick »

This works for us:
  • Image image;
    image.defineValue("tiff", "alpha", "associated");
    image.read( "logo.png" );
    image.write( "logo.tif" );
Notice the define is before the read.
luis.armengol
Posts: 6
Joined: 2012-07-09T05:02:07-07:00
Authentication code: 13

Re: DefineValue("tiff", "alpha", "associated"); not working

Post by luis.armengol »

You are right,

It works perfecly doing only the operation you describe... I will investigate deeper..

My process is getting several pieces of image, compositing them into one bigger image with composite(cuadImage, x, y, CopyCompositeOp); and then saving the complete image. That big image is which is not saving correcly with tiff:alpha associated.

I will post more investigations..

Thanks again
luis.armengol
Posts: 6
Joined: 2012-07-09T05:02:07-07:00
Authentication code: 13

Re: DefineValue("tiff", "alpha", "associated"); not working

Post by luis.armengol »

I give up... I think something happens inside composite that doesnt allow to save that alpha associated info.


This is the last small code I have tested. I have tried to establish everywhere tiff:alpha associated value and other crazy things.
The goal is to composite several images into 1 big image and save it with associated alpha. In this example Im only getting 1 image to composite:

Code: Select all

         // Original Image
         Image image;
         image.defineValue("tiff", "alpha", "associated");
         image.read("/render/bgr/tst0010/scn0001/default_pass/img/bgr_tst0010_scn0001.0101.tif");

         // New Image container to composite the other image
         Image image2;
         image2.defineValue("tiff", "alpha", "associated");
         image2.size("500x500");

         image2.defineValue("tiff", "alpha", "associated");
         image2.backgroundColor("transparent");

         image2.defineValue("tiff", "alpha", "associated");
         image2.composite(image, 0, 0, CopyCompositeOp);

         image2.defineValue("tiff", "alpha", "associated");
         image2.composite(image, 0, 0, CopyOpacityCompositeOp);

         image2.defineValue("tiff", "alpha", "associated");
         image2.write("/render/bgr/tst0010/scn0001/default_pass/img/bgr_tst0010_scn0001.associated.tif");
Post Reply