[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RMagick -- TIF to PDF

paron

7/16/2007 4:48:00 PM

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

2 Answers

Tim Hunter

7/16/2007 5:37:00 PM

0

On Jul 16, 12:47 pm, paron <rphill...@engineer.co.summit.oh.us> 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:
http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=8509&p=26135&hilit=photomet....

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"}

paron

7/18/2007 4:48:00 PM

0


> > 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/discourse-server/viewtopic.php?f=2&t.......
>

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