Difference between revisions of "ExportImage Command"
From GeoGebra Manual
(new command ExportImage()) |
(In the Chrome browser you can specify <code>"clipboard", true</code>) |
||
(18 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
:Exports an image of the currently active view (or the view specified by the "view" parameter) | :Exports an image of the currently active view (or the view specified by the "view" parameter) | ||
− | + | ||
− | ;<code>ExportImage("scale", 5)</code> | + | {{note|1= :* The ''Properties'' used in the command syntax, listed in the following examples, need to be entered in English. |
+ | :*The ''values'' related to the View that will be saved as image are: | ||
+ | ::* 1 for [[File:Menu view graphics.svg|link=|16px]] ''Graphics View'' | ||
+ | ::* 2 for [[File:Menu view graphics2.svg|link=|16px]] ''Graphics View'' 2 | ||
+ | ::* -1 for [[File:Perspectives algebra 3Dgraphics.svg|link=|16px]] 3''D View''}} | ||
+ | |||
+ | |||
+ | {{examples|1=<br> | ||
+ | *;<code>ExportImage("scale", 5)</code> | ||
: Shows a popup of the current view so that the user can right-click -> Save Image As... | : Shows a popup of the current view so that the user can right-click -> Save Image As... | ||
− | ;<code>ExportImage("filename", "image.png")</code> | + | *;<code>ExportImage("filename", "image.png")</code> |
: Saves a file called "image.png" of the current view | : Saves a file called "image.png" of the current view | ||
− | ;<code>ExportImage("filename", "image.png", "view", 2)</code> | + | *;<code>ExportImage("filename", "image.png", "view", 2)</code> |
: Saves a file called "image.png" of Graphics View 2 | : Saves a file called "image.png" of Graphics View 2 | ||
− | ;<code>ExportImage("filename", "image.png", "view", -1)</code> | + | *;<code>ExportImage("filename", "image.png", "view", -1)</code> |
− | : Saves a file called "image.png" of | + | : Saves a file called "image.png" of View 3D Graphics |
− | ;<code>ExportImage("filename", "image.png", "dpi", 300)</code> | + | *;<code>ExportImage("filename", "image.png", "dpi", 300)</code> |
: Saves a file called "image.png" of the current view at 300 dpi (dots-per-inch) | : Saves a file called "image.png" of the current view at 300 dpi (dots-per-inch) | ||
− | ;<code>ExportImage("filename", "image.png", "scale", 2)</code> | + | *;<code>ExportImage("filename", "image.png", "scale", 2)</code> |
: Saves a file called "image.png" of the current view at scale 2 (ie twice nominal screen resolution) | : Saves a file called "image.png" of the current view at scale 2 (ie twice nominal screen resolution) | ||
− | ;<code>ExportImage("filename", "image.png", scalecm", 2, "dpi", 600)</code> | + | *;<code>ExportImage("filename", "image.png", "scalecm", 2, "dpi", 600)</code> |
− | : Saves a file called "image.png" of the current view at | + | : Saves a file called "image.png" of the current view at 600 dpi at a scale 1 unit = 2 cm |
− | ;<code>ExportImage("filename", "image.png", "width", 1000)</code> | + | *;<code>ExportImage("filename", "image.png", "width", 1000)</code> |
: Saves a file called "image.png" of the current view with width = 1000 pixels | : Saves a file called "image.png" of the current view with width = 1000 pixels | ||
− | ;<code>ExportImage("filename", "image.png", "height", 1000)</code> | + | *;<code>ExportImage("filename", "image.png", "height", 1000)</code> |
: Saves a file called "image.png" of the current view with height = 1000 pixels | : Saves a file called "image.png" of the current view with height = 1000 pixels | ||
− | ;<code>ExportImage("filename", "image.svg", "type", "svg")</code> | + | *;<code>ExportImage("filename", "image.png", "transparent", true)</code> |
+ | : Saves a transparent PNG file called "image.png" | ||
+ | : Setting the “transparent” property as ''false'' saves also background images. | ||
+ | |||
+ | *;<code>ExportImage("filename", "image.svg", "type", "svg")</code> | ||
: Saves a file called "image.svg" of the current view in SVG format | : Saves a file called "image.svg" of the current view in SVG format | ||
+ | |||
+ | *;<code>ExportImage("filename", "image.gif", "type", "gif", "slider", a, "loop", true, "time", 200, "width", 400)</code> | ||
+ | : Saves a looping animated GIF of the current view controlled by slider "a" with 200ms between frames. '''Keep the width and number of slider steps small''' | ||
+ | |||
+ | *;<code>ExportImage("filename", "image.gif", "type", "gif", "view", -1, "rotate", 360°, "slider", a, "loop", true, "time", 200)</code> | ||
+ | : Saves a looping animated GIF of the current view controlled by slider "a" with 200ms between frames and rotates the view 360° during the animation. '''Keep the size of the view and the number of steps small''' | ||
+ | |||
+ | *;<code>ExportImage("type", "pdf", "filename", "test.pdf")</code> | ||
+ | : Creates a PDF of the current view (or a 2-page PDF if Graphics View 2 is open) | ||
+ | |||
+ | *;<code>ExportImage("type", "pdf", "filename", "test.pdf", "slider", n)</code> | ||
+ | : Creates a '''multi-page''' PDF of the current view where each page corresponds to one step of the slider "n" | ||
+ | |||
+ | *;<code>pic1 = ExportImage("view", 2, "corner", A, "corner2", B)</code> | ||
+ | : Creates a GeoGebra image of View 2 and puts it in the view with position defined by <code>A</code> and <code>B</code> | ||
+ | |||
+ | }} | ||
{{Notes|1= | {{Notes|1= | ||
− | * In GeoGebra Classic 5 if there is no <code>filename</code> parameter the image will be copied to the clipboard | + | * In GeoGebra Classic 5 if there is no <code>filename</code> parameter the image will be copied to the Clipboard. In the Chrome browser you can specify <code>"clipboard", true</code> |
+ | * To crop an export, make the Points <code>Export_1</code> and <code>Export_2</code> to define the rectangle to crop ('''These also crop the exports from the menus eg File -> Export Image''') | ||
+ | * Some syntaxes aren't supported in GeoGebra 5 Classic | ||
+ | * In Chrome, you can try the experimental syntax <code>"type", "webm"</code> to get a faster & smaller export than with animated GIFs | ||
+ | * For the 2D Graphics Views you can try this syntax to get a monochrome export <code>"grayscale", true</code> (PNG format only) | ||
+ | * For the 3D Graphics View, only bitmaps (eg png, gif) are supported. In GeoGebra Classic 5 you can try this to get a high-resolution output <code>ExportImage("filename", "c:\Users\<username>\AppData\image.png", "view", -1, "width", 2000)</code>. Change '''<username>''' to your Windows username | ||
+ | }} |
Latest revision as of 19:06, 15 July 2021
- ExportImage( <Property>, <Value>, <Property>, <Value>, ... )
- Exports an image of the currently active view (or the view specified by the "view" parameter)
Note:
- The Properties used in the command syntax, listed in the following examples, need to be entered in English.
- The values related to the View that will be saved as image are:
- 1 for Graphics View
- 2 for Graphics View 2
- -1 for 3D View
Examples:
ExportImage("scale", 5)
- Shows a popup of the current view so that the user can right-click -> Save Image As...
ExportImage("filename", "image.png")
- Saves a file called "image.png" of the current view
ExportImage("filename", "image.png", "view", 2)
- Saves a file called "image.png" of Graphics View 2
ExportImage("filename", "image.png", "view", -1)
- Saves a file called "image.png" of View 3D Graphics
ExportImage("filename", "image.png", "dpi", 300)
- Saves a file called "image.png" of the current view at 300 dpi (dots-per-inch)
ExportImage("filename", "image.png", "scale", 2)
- Saves a file called "image.png" of the current view at scale 2 (ie twice nominal screen resolution)
ExportImage("filename", "image.png", "scalecm", 2, "dpi", 600)
- Saves a file called "image.png" of the current view at 600 dpi at a scale 1 unit = 2 cm
ExportImage("filename", "image.png", "width", 1000)
- Saves a file called "image.png" of the current view with width = 1000 pixels
ExportImage("filename", "image.png", "height", 1000)
- Saves a file called "image.png" of the current view with height = 1000 pixels
ExportImage("filename", "image.png", "transparent", true)
- Saves a transparent PNG file called "image.png"
- Setting the “transparent” property as false saves also background images.
ExportImage("filename", "image.svg", "type", "svg")
- Saves a file called "image.svg" of the current view in SVG format
ExportImage("filename", "image.gif", "type", "gif", "slider", a, "loop", true, "time", 200, "width", 400)
- Saves a looping animated GIF of the current view controlled by slider "a" with 200ms between frames. Keep the width and number of slider steps small
ExportImage("filename", "image.gif", "type", "gif", "view", -1, "rotate", 360°, "slider", a, "loop", true, "time", 200)
- Saves a looping animated GIF of the current view controlled by slider "a" with 200ms between frames and rotates the view 360° during the animation. Keep the size of the view and the number of steps small
ExportImage("type", "pdf", "filename", "test.pdf")
- Creates a PDF of the current view (or a 2-page PDF if Graphics View 2 is open)
ExportImage("type", "pdf", "filename", "test.pdf", "slider", n)
- Creates a multi-page PDF of the current view where each page corresponds to one step of the slider "n"
pic1 = ExportImage("view", 2, "corner", A, "corner2", B)
- Creates a GeoGebra image of View 2 and puts it in the view with position defined by
A
andB
Notes:
- In GeoGebra Classic 5 if there is no
filename
parameter the image will be copied to the Clipboard. In the Chrome browser you can specify"clipboard", true
- To crop an export, make the Points
Export_1
andExport_2
to define the rectangle to crop (These also crop the exports from the menus eg File -> Export Image) - Some syntaxes aren't supported in GeoGebra 5 Classic
- In Chrome, you can try the experimental syntax
"type", "webm"
to get a faster & smaller export than with animated GIFs - For the 2D Graphics Views you can try this syntax to get a monochrome export
"grayscale", true
(PNG format only) - For the 3D Graphics View, only bitmaps (eg png, gif) are supported. In GeoGebra Classic 5 you can try this to get a high-resolution output
ExportImage("filename", "c:\Users\<username>\AppData\image.png", "view", -1, "width", 2000)
. Change <username> to your Windows username