Parsing Multi Page Tiffs using VA 7.5.2

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Parsing Multi Page Tiffs using VA 7.5.2

Postby tkrieg » Thu Nov 13, 2008 11:28 am

Hello,
I'm trying to parse a multi-paged Tiff image file using the class CgTIFFFileFormat. Unfortunately when I attempt to load the tiff file using this class it reports the error 'Compression type not supported'.

If I attempt to load a single image Tiff, the CgTIFFFileFormat seems to work fine, so that's why I'm thinking the problem I'm having is because of the multiple images in a single tiff file.

I'd like to have a Smalltalk class that can load multiple images from the .tif file, so I can split them out and individually save them to a SQL server database. Does anyone know if VAST has addressed this problem? I'm definately not a .tiff file expert, and really didn't want to have to become one, so... If someone has already solved this problem, I'd really appreciate advice.

In my code example below I've commented out the multi page file.
Thanks in advance.


| path file readerClass reader image |

"path := 'C:\multipaged.tif'." <== This file doesn't work
path := 'C:\singleImage.tif'. <== This file works
(file := CfsFileDescriptor open: path oflag: 0) isCfsError
ifTrue: [^self error: 'File error' ].
readerClass := CgImageFileFormat
formatMatchingFileHandle: file
atOffset: 0
ifNone: [
file close.
^self error: 'File is not a supported type of bitmapped image' ].

image := (reader := readerClass new) loadFromFileHandle: file atOffset: 0.

reader hasErrorOccurred ifTrue: [ ^self error: 'Unable to load tiff file' ].
file close.

image isNil ifTrue: [ ^self error: reader currentErrorString ].
^image
tkrieg
 
Posts: 4
Joined: Thu Nov 13, 2008 10:45 am

Re: Parsing Multi Page Tiffs using VA 7.5.2

Postby marten » Thu Nov 13, 2008 3:01 pm

There is no support for multi-page tiff's file by VA - you may use free external tiff commands to do what you want - perhaps you might look at http://www.libtiff.org/tools.html and at this page especially: tiffsplit

Marten
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: Parsing Multi Page Tiffs using VA 7.5.2

Postby tkrieg » Thu Nov 13, 2008 3:09 pm

Thanks for the reply Marten,
Does tiffsplit work for with Windows? We're using XP as the client OS.
Thanks,
Tim

marten wrote:There is no support for multi-page tiff's file by VA - you may use free external tiff commands to do what you want - perhaps you might look at http://www.libtiff.org/tools.html and at this page especially: tiffsplit

Marten
tkrieg
 
Posts: 4
Joined: Thu Nov 13, 2008 10:45 am

Re: Parsing Multi Page Tiffs using VA 7.5.2

Postby marten » Fri Nov 14, 2008 12:13 am

tkrieg wrote:Thanks for the reply Marten,
Does tiffsplit work for with Windows? We're using XP as the client OS.
Thanks,
Tim

marten wrote:There is no support for multi-page tiff's file by VA - you may use free external tiff commands to do what you want - perhaps you might look at http://www.libtiff.org/tools.html and at this page especially: tiffsplit

Marten


Yes, there are binaries available for Windows (command line tools). You may also look at the free library "freeImage" - which covers many more graphical stuff, but for the tiff subsystem they also use libTIFF stuff.

Marten
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: Parsing Multi Page Tiffs using VA 7.5.2

Postby marten » Sat Nov 15, 2008 1:07 am

tkrieg wrote:Hello,
I'm trying to parse a multi-paged Tiff image file using the class CgTIFFFileFormat. Unfortunately when I attempt to load the tiff file using this class it reports the error 'Compression type not supported'.


After reading your post, I sat down and wrote yesterday a very simple wrapper around some API calls of the FreeImage library and actually the API calls mapped are suitable to get each page out of a TIFF based file . nothing more, but the library is able to do much more.

You may look at:

http://www.schrievkrom.de/blog/?p=225
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Re: Parsing Multi Page Tiffs using VA 7.5.2

Postby marten » Thu Feb 05, 2009 1:20 pm

I added additional API calls to that wrapper - now there is limited support for png files with a depth of 24 and conversion to CgDeviceIndependentImage, support for crc32 calculation and compression/uncompression. This seems to work for some files, but not for all png files (especially for 32 bbs files and all that).

One of the strange things are, that I have to vertical flip my png images before converting them to CgDeviceIndependentImage, though both formats have their scanlines direction from top to bottom ...
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest