Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the color depth on TIFF files written using the Wand API. #68

Closed
emxjay opened this issue Dec 17, 2015 · 11 comments
Closed

Setting the color depth on TIFF files written using the Wand API. #68

emxjay opened this issue Dec 17, 2015 · 11 comments

Comments

@emxjay
Copy link

emxjay commented Dec 17, 2015

The issue is well explained here.

Can you please clarify this for us?

@mikayla-grace
Copy link

Modern releases of ImageMagick, by default, writes to an image format @ the same depth as the source image assuming the particular image format supports the depth. XBM, for example, only supports images of depth 1, regardless of the source image depth. This is by design. If you find that ImageMagick behaves differently, post a command-line illustrating the exception.

@emxjay
Copy link
Author

emxjay commented Dec 28, 2015

Hi - What do you mean by modern? For instance, the issue above is valid on ImageMagick 6.7.7-10 (which is, btw, shipped w/ the latest release of Ubuntu LTS).

@mikayla-grace
Copy link

When appending an image, the image depth is that of the first image. If your first image has a depth of 1, the output TIFF image has a depth of 1. We'll add a patch to fix this problem. In the mean-time, use setImageDepth(16) to ensure a depth of 16 bits-per-pixel. If it doesn't already, IMagick should also support setDepth(). setImageDepth() is specific to a particular image whereas setDepth() applies to all images in a sequence.

@Danack
Copy link
Contributor

Danack commented Dec 28, 2015

I've just seen that this is a duplicate (or at least caused by the same desire) of #66 .

Are you saying that setDepth() will always control the output image depth?

@emxjay
Copy link
Author

emxjay commented Dec 29, 2015

@mikayla-grace setImageDepth(16) have no effect, unless setType() is specified. And that's the case for every image of the sequence (including the first one). And again, I'm talking about the Wand API, not the command-line tools.

@mikayla-grace
Copy link

Will setDepth() always control the output image depth? Well that depends on the output format. XBM, for example, is limited to a pixel depth of 1 so a setDepth(16) would still return an image of depth 1. ImageMagick typically sets the attributes of the destination image from the source image. Assume two images, the first of depth 1 and the second of depth 8. Write this to TIFF and the first image in the TIFF is of depth 1 and the second of depth 8. Whereas, if you call setDepth(8), both images in the TIFF file will be of depth 8.

setImageDepth() has no effect unless setType() is specified? We'll need a specific use case that we can download and reproduce the problem before we can comment further.

@Danack
Copy link
Contributor

Danack commented Dec 29, 2015

setImageDepth() has no effect unless setType() is specified? We'll need a specific use case that we can download and reproduce the problem before we can comment further.

An example from the other issue is below. Yes, it is in PHP as I find that a lot easier to write than C. If absolutely necessary I can convert it to C.

<?php

$imagick = new Imagick();
$imagick->newPseudoImage(200, 200, 'xc:white');
$imagick->setImageFormat('tiff');
$imagick->setImageDepth(16);
$imagick->writeImage("./output_default.tif");
system('identify ./output_default.tif');


$imagick = new Imagick();
$imagick->newPseudoImage(200, 200, 'xc:white');
$imagick->setType(\Imagick::IMGTYPE_TRUECOLOR);
$imagick->setImageFormat('tiff');
$imagick->setImageDepth(16);
$imagick->writeImage("./output_forceTrueColor.tif");
system("identify ./output_forceTrueColor.tif");

@mikayla-grace
Copy link

We have a patch in ImageMagick to fix this problem. Its a legacy issue specific to TIFF. setImageDepth() does not resolve the problem, instead use setImageType(), setDepth(), or install the latest GIT source.

@emxjay
Copy link
Author

emxjay commented Dec 30, 2015

Are you referring to this patch?

@mikayla-grace
Copy link

The patch sets the appended images depth to the maximum depth of any one image used to build the result. A different patch removes the TIFF legacy algorithm of automatically reducing a TIFF image to a depth of 1 if the image was determined to be grayscale / monochrome.

@emxjay
Copy link
Author

emxjay commented Dec 30, 2015

Sweet. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants