Jump to content

Export images


---
 Share

Recommended Posts

Hello,

Can you export image's  from gom inspect to jpg file and save them on your computer.

So that you take this in  a excel sheet

I would like to do it with scripting.

Thanks

Link to comment
Share on other sites

Images that i make in gom inspect that there are in the pdf report but  van these images i think jpg of png want these to take in to excel report and in no pdf

Edited
Link to comment
Share on other sites

I posted this as a reply to another user, it exports all images from your report pages into a folder that you select-

# -*- coding: utf-8 -*-

import os
import gom


dialog=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \
'<title>Export to folder:</title>' \
'<control id="OkCancel"/>' \
'<size height="100" width="200"/>' \
'<content columns="1" rows="1">' \
'<widget type="input::file" row="0" rowspan="1" column="0" columnspan="1">' \
'<name>folder</name>' \
'<type>directory</type>' \
'<title>choose folder:</title>' \
'<default></default>' \
'<limited>false</limited>' \
'<file_types/>' \
'<file_types_default></file_types_default>' \
'</widget>' \
'</content>' \
'</dialog>')


export_folder = dialog.folder.replace('/', os.sep)

for report in sorted(gom.app.project.reports):
	for element in report.pages[0].elements:
		if element.type == 'figure_snapshot_frame':
			i = 1
			while True:
				if os.path.exists(os.path.join(export_folder, '{} {}.png'.format(report.name, i))):
					i += 1
				else:
					break
			gom.script.report.export_report_image_as_png(images=element, file=os.path.join(export_folder, '{} {}.png'.format(report.name, i)), use_original_size=True, disable_transparency=True)

 

Edited
Link to comment
Share on other sites

  • 2 weeks later...

this should work for .jpg

# -*- coding: utf-8 -*-

import os
import gom


dialog=gom.script.sys.execute_user_defined_dialog (content='<dialog>' \
'<title>Export to folder:</title>' \
'<control id="OkCancel"/>' \
'<size height="100" width="200"/>' \
'<content columns="1" rows="1">' \
'<widget type="input::file" row="0" rowspan="1" column="0" columnspan="1">' \
'<name>folder</name>' \
'<type>directory</type>' \
'<title>choose folder:</title>' \
'<default></default>' \
'<limited>false</limited>' \
'<file_types/>' \
'<file_types_default></file_types_default>' \
'</widget>' \
'</content>' \
'</dialog>')


export_folder = dialog.folder.replace('/', os.sep)

for report in sorted(gom.app.project.reports):
	for element in report.pages[0].elements:
		if element.type == 'figure_snapshot_frame':
			i = 1
			while True:
				if os.path.exists(os.path.join(export_folder, '{} {}.jpg'.format(report.name, i))):
					i += 1
				else:
					break
			gom.script.report.export_report_image_as_png(images=element, file=os.path.join(export_folder, '{} {}.jpg'.format(report.name, i)), use_original_size=True, disable_transparency=True, format='JPEG')

 

Link to comment
Share on other sites

  • 4 months later...
 Share

×
×
  • Create New...