Opened 10 years ago

Last modified 5 years ago

#7345 needs_info enhancement

New libtiff package

Reported by: timdumol Owned by: timdumol
Priority: major Milestone:
Component: packages: optional Keywords: sd32
Cc: Merged in:
Authors: Tim Dumol Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by timdumol)

This is used by PIL (c.f. #7273). Inclusion as an optional or even as a standard package would be helpful.

The package is here: http://sage.math.washington.edu/home/timdumol/libtiff-3.9.5.spkg

Change History (21)

comment:1 Changed 10 years ago by mpatel

Should this belong to a different component?

comment:2 Changed 10 years ago by timdumol

  • Component changed from notebook to packages
  • Status changed from new to needs_review

Woops. Yep.

comment:3 Changed 10 years ago by jhpalmieri

  • Report Upstream set to N/A
  • Status changed from needs_review to needs_work

Builds fine on Mac OS X 10.6 and sage.math, and installs what look like the right libraries in the right place. What can I do to test it?

I've marked it as "needs work" because the SPKG.txt file says "libjpeg" several places instead of "libtiff".

Is the spkg-install file modeled after other ones currently in use? (Will drkirby complain about gnuisms, for instance, or is this derived from one of his spkg-install files?)

comment:4 Changed 10 years ago by jhpalmieri

Oh, there is also a file SPKG.txt~ which should not be there.

comment:5 Changed 9 years ago by kcrisman

See also here.

comment:6 Changed 9 years ago by boothby

  • Owner changed from boothby to timdumol

comment:7 Changed 9 years ago by timdumol

  • Description modified (diff)
  • Status changed from needs_work to needs_review

Updated version found here: http://sage.math.washington.edu/home/timdumol/libtiff-3.9.4.spkg

This should fix the OS X 10.6 problems (c.f. #7344).

sage: import Image
sage: im = Image.open("<your-tiff-file-here>")
sage: im = im.resize((im.size[0]/2,im.size[1]/2))
sage: print im.format, im.size, im.mode
TIFF (455, 495) 1
sage: im.show()
sage: im.save("wherever.tiff")

comment:8 Changed 8 years ago by mariah

  • Status changed from needs_review to needs_info

http://libtiff.org says latest version is 3.6.1, yet this spkg is labeled 3.9.4. Why?

comment:9 Changed 8 years ago by timdumol

  • Status changed from needs_info to needs_review

The web page itself is outdated. The downloads page: ftp://ftp.remotesensing.org/pub/libtiff actually states that the latest package is 3.9.5.

comment:10 Changed 8 years ago by timdumol

  • Status changed from needs_review to needs_work

comment:11 Changed 8 years ago by timdumol

  • Description modified (diff)
  • Status changed from needs_work to needs_review

comment:12 Changed 8 years ago by jhpalmieri

  • Status changed from needs_review to needs_work

There are some problems on OS X:

sage: im = Image.open('/Users/palmieri/Desktop/P1000717.tiff')
sage: im.show()
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
...
IOError: encoder jpeg not available
sage: im = im.resize((im.size[0]/2,im.size[1]/2))
sage: print im.format
None

By the way, according to ImageMagick's "identify" program:

$ identify P1000717.tiff 
P1000717.tiff TIFF 3648x2736 3648x2736+0+0 DirectClass 8-bit 28.5613mb 

So I think it's the right format to be opened by this library. Is there anything else I should check?

comment:13 follow-up: Changed 8 years ago by timdumol

  • Status changed from needs_work to needs_review

In the notebook, im.show() saves a JPEG into the worksheet directory, which is then automatically displayed by the SageNB. Thus, the error you got was actually because PIL has no access to libjpeg, and is thus not related to this package.

comment:14 Changed 8 years ago by jhpalmieri

  • Status changed from needs_review to needs_info

I was actually working from the command line, but anyway, what about this part:

sage: im = im.resize((im.size[0]/2,im.size[1]/2))
sage: print im.format
None

According to the earlier example, this should have said "TIFF".

comment:15 Changed 8 years ago by jhpalmieri

By the way, I can successfully save the resized image. Somewhere along the line I reinstalled PIL, so I don't know if that's necessary.

comment:16 Changed 8 years ago by jhpalmieri

Two things: since this package installs files into SAGE_ROOT/local/bin, you should add those files to .hgignore — this will require a separate patch to the scripts repo. Also the spkg file contains "SPKG.txt~", which shouldn't be there.

comment:17 in reply to: ↑ 13 Changed 8 years ago by leif

Replying to timdumol:

In the notebook, im.show() saves a JPEG into the worksheet directory, which is then automatically displayed by the SageNB.

May I ask why? Does it make any sense to convert a "lossless image" into a lossy format, i.e., why not convert it to e.g. PNG which any (GUI) browser should be able to display?

(I know TIFF is also a "meta format", i.e. you can encapsulate JPEGs in a TIFF file, but John's example file doesn't look like it was such.)

The only reason I can imagine is that it's easier to scale JPEG images than bitmaps, but unless we include the batteries by default, a simple show() of a bitmap image shouldn't require libjpeg.

comment:18 Changed 8 years ago by was

  • Keywords sd32 added

comment:19 Changed 8 years ago by janssen

Regarding the im.format printing as None, that's OK, since the format attribute is only defined if the image was loaded from a file.

Regarding the action of Image.show(): Leif is right, using JPEG is a bad idea. Using TIFF is also a bad idea, for this purpose, as the PIL TIFF encoder only saves uncompressed TIFF files. They're big and slow. I second the idea of using PNG for Image.show(). But that really is a separate issue, and should be broken out as such.

comment:20 Changed 8 years ago by janssen

Hmm, I see that JPEG is hard-coded into PIL 1.1.6. In PIL 1.1.7, im.show() uses a non-lossy format, and the user can override the viewer used by show(), so one custom-designed for Sage could be put in there if necessary.

comment:21 Changed 5 years ago by jdemeyer

  • Component changed from packages: standard to packages: optional
Note: See TracTickets for help on using tickets.