VintaSoft Twain .NET SDK Discussions

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Board index < VintaSoft Twain < VintaSoft Twain .NET SDK Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

Img Compression before Save() to SQL DB



Img Compression before Save() to SQL DB

Post by htaylor »

I have this working but saving to a DB over the network is very slow (30 sec) even at 72 d.p.i. unless the lowest scanner settings are selected. No matter what resolution the user scans at I want to force 8-bit grayscale at 72 d.p.i. THEN compress the file to speed things up.

Does any one have any compression code?

I have been looking but it has eluded me.


Re: Img Compression before Save() to SQL DB

Post by htaylor »

For those interested I have decided not to allow user storage in the database as there is nothing to prevent the storage of illegal images. You may wish to re-think DB storage if you have a commercial application - could be bad for the Corporate image if it hit the headlines a child molester used your tools and database to store bad pictures.


Re: Img Compression before Save() to SQL DB

Post by Alex »

Hello Taylor,

Here is a snippet of code that saves images to stream in PDF format:
Public Sub ScanWithUI()
    Dim mem As MemoryStream = Nothing
    VSTwain1.AppProductName = "MyTwainApplication"
    Try
        VSTwain1.StartDevice()
        VSTwain1.SelectSource()
        VSTwain1.ShowUI = true
        VTwain1.MaxImages = 1
        Dim firstImage As Boolean = True
        While VSTwain1.AcquireModal()
            If firstImage Then
                ' Create memory stream and place the first image to it
                mem = VSTwain1.GetImageAsStream(0, ImageFileFormat.PDF)
                firstImage = False
            Else
                ' Add second and next images to the stream
                VSTwain1.SaveImageToStream(0, mem, ImageFileFormat.PDF)
            End If
        End While
    Catch ex As TwainException
        MsgBox ex.Message
    Catch ex As ImagingException
        MsgBox ex.Message
    End Try
    ...
    ' Uploading stream data to server or doing something else...
    ...
End Sub
Also please read description of the SaveImageToStream method in documentation.

Best regards, Alexander


Page 1 from 1: 1