Home Image-Pro Automation (Macros, Apps, Reports)

TIF IMAGE FILE SAVE with LZW MODE ON . . .

2018-11-14-110830

All --

Is there a way to control TIF IMAGE FILE COMPRESSION via CODE?

Background . . .

When saving a TIF IMAGE in IMAGE-PRO, there are three options for compression.  They are:
  1. NONE
  2. LZW
  3. LZW AND DIFFERNENCING
I have a customer that saves their TIF IMAGES with LZW.

I have written an APP for them that needs to maintain their ORIGINAL TIFF (with LZW) IMAGE FILE but I would like to create a WORKING COPY TIFF (with LZW) IMAGE FILE.

It seems that when IMAGE-PRO saves a TIF IMAGE FILE, the COMPRESSION OPTION that is used is only controllable via the SAVE AS DIALOG BOX.

If CODE does a SAVE AS, the COMPRESSION OPTION that will be used is the last one that was used via the SAVE AS DIALOG BOX.

I have recorded saving TIF IMAGES using each COMPRESSION OPTION but no difference is shown in the RECORDED CODE. 

So . . .

Is there a way to control TIF IMAGE FILE COMPRESSION via CODE?

Thanks.

-- Matt


Answers

  • Matt,

    Here is a macro to do that:

        Public Function SaveLZWDiff() As SimpleScript
            SaveLZWDiff = New SimpleScript
            Dim image1
    
            With Application.DocumentCommands.ActiveImage(SaveLZWDiff)
                .Run(image1)
            End With
    
            With Automate.ScriptingCommands.CodeCommand(SaveLZWDiff)
                If .Run() Then
                    ' User Code Here
                    Dim image As McImage = image1
                    image.File.Compression=MediaCy.IQL.IO.mcscCompression.mcscLZWDiff
                End If
            End With
    
            With Application.DocumentCommands.SaveAs(SaveLZWDiff)
                .Filename = ThisApplication.Path(mcPathType.mcptWritableImages) & "Test.tif"
                .Run(image1)
            End With
    
        End Function
  • And a shorter version:
        Public Sub SaveLZWDiff2
            With ThisApplication.ActiveImage
                .File.Compression=MediaCy.IQL.IO.mcscCompression.mcscLZWDiff
                .SaveAs(ThisApplication.Path(mcPathType.mcptWritableImages) & "Test.tif")
            End With
        End Sub
  • BTW, in both cases you will need a reference to MediaCy.IQL.IO.dll which is not there by default.

    Pierre
  • 2018-11-16-094433

    Pierre --

    Thank you very much for this information.  The size difference between the LZW TIF and the TIF is SIGNIFICANT so this customer will very much appreciate the LZW OPTION.

    -- Matt


Sign In or Register to comment.