From: Tony Girgenti on
Hello Shotgun.

I found this at codeproject.com:

tifInputPageConvert24Long = FreeImage_ConvertTo24Bits(tifInputPageLong)

That gave me the four jpg files. I'm converting each jpg page before saving
it using the above code.

>> Do know the compression format of the TIFF's you're using?<<

I'm glad you asked that, because i am in the process of trying to use this:

Dim tifInputImageTypeFIT As FREE_IMAGE_TYPE
Dim tifInputImageWidth As Long
dib = FreeImage_OpenMultiBitmap(FIF_TIFF, "C:\test.tif", 0, 1, 1, 0)
tifInputImageTypeFIT = FreeImage_GetImageType(dib)

For 'tifInputImageTypeFIT' i'm getting a big number like 50091600 or
61055520. It's always something different, but it's never something that i
can interpret as an image type. 'FreeImage_GetImageType' is supposed to
return the data type of the bitmap.

Thanks,
Tony


"Shotgun Thom" wrote:

> On Mar 4, 3:37 pm, Tony Girgenti <tony(nospam)@lakesideos.com> wrote:
> > Karl and Shotgun,
>
> > [FreeImage] Error: only 24-bit highcolor or 8-bit greyscale/palette bitmaps
> > can be saved as JPEG
> > Image: JPEG
> > Code: 2
> >
> > I am currently working on trying to figure how to tell FreeImage to use the
> > last parameter in this statement:
> >
> > jpgOutputPageLong = FreeImage_Save(FIF_JPEG, dib, "c:\test" &
> > pageCountInteger + 1 & ".jpg", JPEG_DEFAULT)
>
> I've not used FreeImage so I can't specifically tell you the process
> to use with this package. However, the error message you wrote
> indicates that you may be trying to convert a 1bit (ccitt4
> compression) TIFF. The TIFF format has several different types of
> compression. The two most often seen are LZW and CCITT4. The CCITT4
> is basically a 1bit B&W format most often used for archiving (because
> the file size is small) or faxing. The error message is telling you
> that the minimum color depth for JPEG's is 8bit (256 color or
> greyscale).
>
> Do know the compression format of the TIFF's you're using?
>
> Tom
> .
>
From: Shotgun Thom on
On Mar 5, 12:39 pm, Tony Girgenti <tony(nospam)@lakesideos.com> wrote:
> Hello Shotgun.
>
> I found this at codeproject.com:
>
>     tifInputPageConvert24Long = FreeImage_ConvertTo24Bits(tifInputPageLong)
>
> That gave me the four jpg files.  I'm converting each jpg page before saving
> it using the above code.
>
> >> Do know the compression format of the TIFF's you're using?<<
>
> I'm glad you asked that, because i am in the process of trying to use this:
>
> Dim tifInputImageTypeFIT As FREE_IMAGE_TYPE
> Dim tifInputImageWidth As Long
> dib = FreeImage_OpenMultiBitmap(FIF_TIFF, "C:\test.tif", 0, 1, 1, 0)
> tifInputImageTypeFIT = FreeImage_GetImageType(dib)
>
> For 'tifInputImageTypeFIT' i'm getting a big number like 50091600 or
> 61055520.  It's always something different, but it's never something that i
> can interpret as an image type. 'FreeImage_GetImageType' is supposed to
> return the data type of the bitmap.
>
> Thanks,
> Tony
>
>
>
> "Shotgun Thom" wrote:
> > On Mar 4, 3:37 pm, Tony Girgenti <tony(nospam)@lakesideos.com> wrote:
> > > Karl and Shotgun,
>
> > > [FreeImage] Error: only 24-bit highcolor or 8-bit greyscale/palette bitmaps
> > > can be saved as JPEG
> > >             Image: JPEG
> > >             Code:  2
>
> > > I am currently working on trying to figure how to tell FreeImage to use the
> > > last parameter in this statement:
>
> > > jpgOutputPageLong = FreeImage_Save(FIF_JPEG, dib, "c:\test" &
> > > pageCountInteger + 1 & ".jpg", JPEG_DEFAULT)
>
> > I've not used FreeImage so I can't specifically tell you the process
> > to use with this package.  However, the error message you wrote
> > indicates that you may be trying to convert a 1bit (ccitt4
> > compression) TIFF.  The TIFF format has several different types of
> > compression.  The two most often seen are LZW and CCITT4.  The CCITT4
> > is basically a 1bit B&W format most often used for archiving (because
> > the file size is small) or faxing.  The error message is telling you
> > that the minimum color depth for JPEG's is 8bit (256 color or
> > greyscale).
>
> > Do know the compression format of the TIFF's you're using?
>
> > Tom
> > .- Hide quoted text -
>
> - Show quoted text -

Look to see if FreeImage has the ability to read EXIF information.
Stored in TIFF files under keyword "Compression" is the type
compression used on that image as an EXIF tag. For a 1bit B/W it will
return something like T/6 Group 4 Fax or perhaps just the number 4 or
even ccitt4. EXIF is string information stored in the file itself.

Tom
From: Karl E. Peterson on
Hi Tony --

> Here is my whole procedure. I tried changing the 'dib' and still get the
> same error.

Well, you need to realize how hard it can be to troubleshoot code on
sight alone, without the data it's attempting to work on. Especially
in a case like this, where there is no easily describable data one
might test against. Then, you also need to realize that I can *easily*
tell that's not the code you're running into troubles with, which
leaves me to question why I should spend any time reading it at all.
Y'see, I spent many years tech reviewing code for VBPJ, including
thousands of reader submissions. Code typed directly into an email or
newspost was rejected on sight nearly without exception. Life's too
short.

Anyway, I wouldn't mind helping, as this is a library I'm always
interested in learning better myself. I did take a quick look at
what's below, though, and it appears you ignored my last post entirely?
Please pay *careful* attention to the return value from FI_LockPage
and the parameters for FI_Save. You seem to (still) be passing the
entire multipage graphic to the latter, rather than just the page
desired.

Thanks... Karl


> Thanks for any help that you can provide.
>
> Tony
>
> Private Sub btnTest_Click()
>
> Dim dib As Long
> Dim bOK As Long
> Dim pageCountOfImage As Long
> Dim pageOfImage As Long
> Dim pageCountInteger As Integer
> Dim jpgOutputPageLong As Long
> Dim tifInputPageLong As Long
> Dim tifInputImageTypeFIT As FREE_IMAGE_TYPE
> Dim tifInputImageWidth As Long
>
> FreeImage_InitErrorHandler
> dib = FreeImage_OpenMultiBitmap(FIF_TIFF, C:\test.tif", 0, 1, 1, 0)
> tifInputImageTypeFIT = FreeImage_GetImageType(dib)
> tifInputImageWidth = FreeImage_GetWidth(dib)
> pageCountOfImage = FreeImage_GetPageCount(dib)
>
> For pageCountInteger = 0 To pageCountOfImage - 1
>
> tifInputPageLong = FreeImage_LockPage(dib, pageCountInteger)
> jpgOutputPageLong = FreeImage_Save(FIF_JPEG, dib, "c:\test" &
> pageCountInteger + 1 & ".jpg", JPEG_DEFAULT)
> Call FreeImage_UnlockPage(dib, tifInputPageLong, 0)
>
> Next pageCountInteger
>
> bOK = FreeImage_CloseMultiBitmap(dib, 0)
> FreeImage_Unload (dib)
>
> End Sub

--
..NET: It's About Trust!
http://vfred.mvps.org