Forum

Author Topic: Convert Images via Python  (Read 5687 times)

ScottB

  • Newbie
  • *
  • Posts: 14
    • View Profile
Convert Images via Python
« on: September 26, 2021, 07:58:18 AM »
Quick question,

what is the python command for the equivalent to:

File -> Export -> Convert Images??

Is it exportRater and if so is there an example of this??



Thanks,



Scott.

Paulo

  • Hero Member
  • *****
  • Posts: 1573
    • View Profile
Re: Convert Images via Python
« Reply #1 on: September 26, 2021, 12:36:05 PM »
Hi Scott,

I think you look at class ConvertImages in API reference manual p.130...

Best Regards,
Paul Pelletier,
Surveyor

ScottB

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Convert Images via Python
« Reply #2 on: September 27, 2021, 06:55:33 AM »
Hi,

Again thanks, this works perfectly.

For the sake of others this is the code...

Code: [Select]
for chunk in doc.chunks:
    for camera in chunk.cameras:
        if camera.enabled:
            newcams.append(camera)

    task = Metashape.Tasks.ConvertImages()
    task.cameras = newcams
    task.path = "C:/myData/myImages/{filename}.jpg"
    task.remove_distortions = True
    task.update_gps_tags = True
    task.fix_principal_point = True
    task.fix_pixel_aspect = True
    task.apply(chunk)



Again thanks for the support, appreciated.


Scott.

Paulo

  • Hero Member
  • *****
  • Posts: 1573
    • View Profile
Re: Convert Images via Python
« Reply #3 on: September 27, 2021, 08:03:02 AM »
Hey ScottB,

great to see you got that task spot on!
Best Regards,
Paul Pelletier,
Surveyor