RMagick -- TIF to PDF

P

paron

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
 
R

rmagick

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:
http://www.imagemagick.org/discours...p?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"}
 
P

paron

I'm not a big TIFF user, but I think you're seeing an instance of the
condition discussed here: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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top