Page 1 of 1

.TIF file turns "reverse video"

Posted: 2009-06-12T12:33:51-07:00
by pitosalas
I open a .tif file, and do some manipulation (e.g. image::crop, but I think I've seen it happening elsewhere).

Then I write out the image to a .tif file again.

When I view the file it looks like all the blacks are white and all the whites are black.

Can anyarne explain this? Thanks!

Pito

Re: .TIF file turns "reverse video"

Posted: 2009-06-12T14:24:15-07:00
by magick
Post a URL to your image so we can download it an reproduce the problem. Also post the ImageMagick version you are using.

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T11:22:47-07:00
by pitosalas
# Program that shows problem

require 'rubygems'
require 'RMagick'
include Magick

img = ImageList.new("regular.tif")
img = img[0].rotate(1.0)
img.write("reverse.tif")


# Input file http://www.salas.com/elect/regular.tif
# Output file http://www.salas.com/elect/reverse.tif

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T13:22:37-07:00
by magick
Perhaps there is a problem with your release of ImageMagick. We're using ImageMagick 6.5.3-7 and the conversion produces the expected results (i.e. no reverse video):
  • -> convert regular.tif reverse.tif
    -> compare -metric rmse regular.tif reverse.tif null:
    0 (0)

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T13:28:23-07:00
by pitosalas
Hmm.. I am using

ImageMagick 6.5.1-0 2009-04-24 Q16 http://www.imagemagick.org

The date seems so recent that I didn't imaging it was out of date :)

Let me update and see if things get better...

Thanks,

Pito

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T13:47:45-07:00
by pitosalas
Do you know who maintains the Mac Ports version of ImageMagick? Because when I distribute my software it will be a pain if it requires a non-ports install. Right now the Ports version is the one I am using and that apparently has the problem. Any chance of updating the ports version with the latest?

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T14:15:21-07:00
by magick
Verify the bug exists. Type
  • -> convert regular.tif reverse.tif
    -> compare -metric rmse regular.tif reverse.tif null:
Does ImageMagick 6.5.1-0 return something other than 0.0? If so you can contact the Mac Port maintainer to upgrade to fix the problem. We are not connected with Mac Ports so we cannot help you.

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T14:27:21-07:00
by pitosalas
Here's what I get:

$ convert regular.tif reverse.tif
$ compare -metric rmse regular.tif reverse.tif null:
0 (0) @ 0,0

But what do those steps do and how are they checking that the reverse video isn't happening when I do a rotate?

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T14:42:38-07:00
by magick
Are you rotating by 1 degree? When you do, it promotes your monochrome image to truecolor. To restore the original 1-bit image use this command:
  • convert regular.tif -rotate 1 -threshold 50% image.tif

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T14:57:30-07:00
by pitosalas
Yes I was rotating by 1 degree so that probably explains that.

1) are there any ways to rotate a b&w image that don't turn it to true color?

2) I missed the color conversion side effect of rotate in the doc; is there a reference of what other functions do that? And does it have anything to do with the file starting out as a .tif?

Thanks as usual for the excellent help!!

- Pito

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T15:00:21-07:00
by magick
The problem appears to be saving 1-bit TIFF images with an alpha channel, we're investigating. The alpha channel is created when you rotate. From the command line you can turn it off with the +matte option. Try it and see if that fixes the problem.

Re: .TIF file turns "reverse video"

Posted: 2009-06-15T17:22:43-07:00
by pitosalas
With RMagick it didn't seem to work, in other words, revers1.tif still is reverse video:

require 'rubygems'
require 'RMagick'
include Magick

img = ImageList.new("regular.tif")
img = img[0]
img.alpha(DeactivateAlphaChannel)
img = img.rotate(1.0)
img.write("revers1.tif")

Opposite results on the command line -- reverse2.tif is looks ok:

convert -rotate 1 +matte regular.tif reverse2.tif

Re: .TIF file turns "reverse video"

Posted: 2009-06-22T13:17:10-07:00
by pitosalas
I can see this happen even when there's no rotate (directly) involved. Also I don't understand how the transparency layer could make the image look 'reverse video'. So it doesn't seem to me to be tied to rotate. Does anyone see what might be going on?