# RMagick -- TIF to PDF

**URL:** <https://www.ruby-forum.com/t/rmagick-tif-to-pdf/109548>\
**Category:** Ruby\
**Created:** [July 16, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/rmagick-tif-to-pdf/109548 "2007-07-16T19:27:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecb155/32.png) [@paron](https://www.ruby-forum.com/u/paron)\
**Post date:** [July 16, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/rmagick-tif-to-pdf/109548/1 "2007-07-16T19:27:46Z")

</div>

This works:

require ‘RMagick’  
img\_array = Magick::Image.read(‘C:/test.tif’)  
imgs = Magick::ImageList.new  
for image in img\_array  
image = image.negate  
image.compression= Magick::LZWCompression  
imgs\<\<image  
end

imgs.write(‘C:/testImg1.pdf’)

but it seems like the long way around the barn. Anyone care to suggest  
improvements?

Especially:

image = image.negate.

If that isn’t in there, the PDF comes out the negative of the TIF,  
but it seems like it ought to be unnecessary. Is it a bug, or did I do  
something silly?

Ron

---

<div class="post-metadata">

**Author:** ![paron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecb155/32.png) [@paron](https://www.ruby-forum.com/u/paron)\
**Post date:** [July 16, 2007, 7:43pm UTC](https://www.ruby-forum.com/t/rmagick-tif-to-pdf/109548/2 "2007-07-16T19:43:48Z")

</div>

On Jul 16, 12:47 pm, paron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> image = image.negate.
> 
> If that isn’t in there, the PDF comes out the negative of the TIF,  
> but it seems like it ought to be unnecessary. Is it a bug, or did I do  
> something silly?

I’m not a big TIFF user, but I think you’re seeing an instance of the  
condition discussed here:  
[may I continue post here if it is now a request for feature? - Legacy ImageMagick Discussions Archive](http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=8509&p=26135&hilit=photometric#p26135).

You can use the Image::Info#[]= method to define format-specific  
options, assuming you have a version of ImageMagick that supports the  
option. I’m not at a place where I can test it, but it woudl be  
something like this

imgs = Magick::Image.read(‘C:/test.tif’) {self[“tiff”,  
“quantum:polarity”] = “min-is-black”}

---

<div class="post-metadata">

**Author:** ![paron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecb155/32.png) [@paron](https://www.ruby-forum.com/u/paron)\
**Post date:** [July 18, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/rmagick-tif-to-pdf/109548/3 "2007-07-18T19:34:33Z")

</div>

> > image = image.negate.
> 
> > If that isn’t in there, the PDF comes out the negative of the TIF,  
> > but it seems like it ought to be unnecessary. Is it a bug, or did I do  
> > something silly?
> 
> I’m not a big TIFF user, but I think you’re seeing an instance of the  
> condition discussed here:[may I continue post here if it is now a request for feature? - Legacy ImageMagick Discussions Archive](http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=8509&)…

Well, just to close out the thread, it turns out that it’s not a bug,  
and I didn’t do anything silly. The TIF specification does not set a  
default for the “Photometric” tag, which tells whether min is black or  
min is white.

In fact, the tag doesn’t have to be present at all. Our scanner  
produces TIF files without a “Photometric” tag. Since there’s also no  
default value called out in the spec, it’s a coin-toss whether the  
image renders properly or not in a viewer. That explains why most TIF-  
oriented viewers have an ‘invert image’ button!

Anyway, I don’t think much of that part of the spec. Instead of  
setting a meaningful standard, they apparently just legitimized the  
bag of worms that existed when they wrote it.

If traffic engineers couldn’t agree on whether green or red meant  
“go,” so they just agreed that you could choose either one, that would  
be foolish. If they compounded the problem by deciding that you don’t  
have to tell anyone which option you chose, that is insane.

Ron
