X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



3210 Rate this article:
No rating

Saving iImage as PNG, etc. - An Example Demonstrating iTools Macros

Note: IDL 8.x has now introduced a new set of graphical functions, based on iTools, that are more flexible and easy to use. We recommend the user to experiment with those new graphic functions as well.

Topic

IDL users may be surprised at the default behavior of exporting iImage to any well-known image format file (like PNG, TIFF, GIF, JPEG, etc.). Most iTools users probably want just the image "object" to be stored in the file, not a snapshot of the whole iTools window with all its whitespace margins around the image.

This behavior matches the behavior of exporting iPlots, iSurfaces and all other iTools visualizations (where the margins - holding axes labels, sometimes legends and colorbars and such - almost always play an important role). For this reason, it is unlikely that the iTools development team would want to change this default behavior just for the sake of iImage. Nevertheless, it is actually very easy for an iImage user to implement a very automatic method for exporting just the image limits, with no margins. This tech tip is designed to show the easy steps for creating this automatic method. This tech tip, then, has the added benefit of providing a good, practical example of how to implement and use an iTools Macro.

 

Discussion

Here are the steps that will set up your iImage tool to automatically save only the data (both image data and annotations) that lie within the image borders:

  1. Set up your display with annotation and all, ready to export.

  2. Click 'Operations -> Macros -> Start Recording'.
    In the subsequent 'Start Recording' dialog, click 'OK'. [If you thought you might have any manipulator steps before you save your image, you would change the default 'False' value of the 'Record manipulator steps' field.]

  3. Click 'Window -> Visualization Browser'
    This will bring up a view of the iImage graphics objects hierarchy.

  4. Double-click on the 'View_1' folder
    This will bring up the Properties page of the iImage's "viewplane".

  5. Change the 'X Margin' and 'Y Margin' properties to 0
    It is the iTools default values for these properties that gives a wide margin to the initial iImage view. Change these defaults to 0.

  6. Close the Visualization Browser window.
    Notice how the borders of the view in the iImage window fit exactly the image size.

  7. Export the new view to an image file format.
    Click on 'File -> Export... -> To a File -> Next>> -> select View_1 -> Next>>', then fill in the appropriate options in the 'IDL Data Export Wizard: Step 3 of 3' dialog. Your exported image should now show just your image data.

  8. Complete the Macro recording.
    Click on 'Operations -> Macros -> Stop recording'. In the subsequent iTools Macro Editor dialog, change the default Macro name "New Macro" to something more intuitive, e.g."Save as PNG".

The next time you create an iImage that you want to save as [in my case] a PNG image, you just need to, after completing your iImage display, click on 'Operations -> Macros -> Run Macro ... -> Save as PNG' [or whatever you called your macro], and the image file will be created automatically according to your exact specifications.

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »