.TIF file turns "reverse video"

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pitosalas

.TIF file turns "reverse video"

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: .TIF file turns "reverse video"

Post 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.
pitosalas

Re: .TIF file turns "reverse video"

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: .TIF file turns "reverse video"

Post 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)
pitosalas

Re: .TIF file turns "reverse video"

Post 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
pitosalas

Re: .TIF file turns "reverse video"

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: .TIF file turns "reverse video"

Post 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.
pitosalas

Re: .TIF file turns "reverse video"

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: .TIF file turns "reverse video"

Post 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
pitosalas

Re: .TIF file turns "reverse video"

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: .TIF file turns "reverse video"

Post 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.
pitosalas

Re: .TIF file turns "reverse video"

Post 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
pitosalas

Re: .TIF file turns "reverse video"

Post 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?
Post Reply