SAVING IMAGES IN TIF AND JPG FORMATS . . .
All --
I am having some problems getting IMAGE-PRO 10.0.7 to save images the way that I want.
I am doing a SNAPSHOT of an image which contains some LINE PROFILE INFORMATION in an OVERLAY. The SNAPSHOT generates an image which is approximately 3000 x 2000. I am would like to save this image as TIF and as a JPG.
I recorded the CODE below and the files that resulted are exactly what I want. The TIF IMAGE was approximately 17 MB and the JPG FILE was approximately 1 MB.
I altered the CODE to accept a FILE NAME (with no extension).
When I call the MMBSaveDead CODE, the TIF FILE that is generated by this code is approximately 17 MB. The JPG FILE that is generated by this code is also approximately 17 MB so I don't think that IMAGE-PRO is responding to the CODE in the same was as it responds to the UI when the CODE was generated.
Q1 -- How does MMBSaveDead need to be altered to resolve this issue so that the JPG FILE is truly a JPG FILE?
Q1 -- Can MMBSaveDead be altered to save the image in a TIF FILE using LZW COMPRESSION?
In the past, I have been directed to use something like the code below to save an image in a TIF FILE,
'Save the active image in the appropriate TIF FILE ThisApplication.ActiveImage.File.Format = _ "tif" ThisApplication.ActiveImage.SaveAs _ ( _ TempNewImageFullName _ )
This works but I cannot track down the HELP FILE PAGE that tells me the options for the
ThisApplication.ActiveImage.File.Format
and replacing "tif" with "jpg" results in an IMAGE-PRO CRASH.
Thank you in advance.
-- Matt
Public Function MMBSaveDead(MyImageFileName As String) Dim window1, image1, doc1 With Application.WindowCommands.Active(Nothing) .Run(window1) End With With Application.WindowCommands.Snap(Nothing) .Run(window1, image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(image1, doc1) End With With Application.DocumentCommands.SaveAs(Nothing) .Filename = MyImageFileName & ".tif" .Run(image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(doc1, doc1) End With With Application.DocumentCommands.SaveAs(Nothing) .Filename = MyImageFileName & ".jpg" .Run(image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(doc1, doc1) End With End Function
0
Answers
-
Hi Matt,
I can reproduce your issue and it looks like once the image was saved to TIF, saving it second time with different extension, saves it also as TIF, but with different extension.
We will look into the issue, but for now you can use a simple workaround, just save to JPG format first and then to TIF, like this:Public Function MMBSaveDead(MyImageFileName As String) Dim window1, image1, doc1 With Application.WindowCommands.Active(Nothing) .Run(window1) End With With Application.WindowCommands.Snap(Nothing) .Run(window1, image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(image1, doc1) End With With Application.DocumentCommands.SaveAs(Nothing) .Filename = MyImageFileName & ".jpg" .Run(image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(doc1, doc1) End With With Application.DocumentCommands.SaveAs(Nothing) .Filename = MyImageFileName & ".tif" .Run(image1) End With With Application.DocumentCommands.Activate(Nothing) .Run(doc1, doc1) End With End Function
Regards,
Yuri0 -
2020-09-02-124810Yuri --Thank you for the diagnosis and the solution.Will do.
'Save the active image in the appropriate TIF FILE ThisApplication.ActiveImage.File.Format = _ "tif" ThisApplication.ActiveImage.SaveAs _ ( _ TempNewImageFullName _ )
Is there a version of this CODE that would achieve the same results and is there a way to save the IMAGE in a TIF FILE with LZW COMPRESSION?Thanks again.-- Matt
0 -
Hi Matt,
You can set the Compression property of File to use LZW.
Here is a sample macro that saves active image to files with LZW and no compression:Public Sub SaveWithLZW Dim im As McImage=ThisApplication.ActiveImage With im.File .Format="TIF" .Compression=2'TIFFCOMP_LZWDiff im.SaveAs("D:\TestLZW.tif") .Compression=0'no compression im.SaveAs("D:\TestNoCompression.tif") End With End Sub
Yuri0 -
2020-09-03-140547Yuri --Thank you for the response withSub SaveWithLZWThis may be helpful for this customer due to the number of image files they are generating.Thanks again.-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions