Forum

Author Topic: Change image file type  (Read 4867 times)

Move United

  • Newbie
  • *
  • Posts: 1
    • View Profile
Change image file type
« on: August 05, 2016, 04:21:40 PM »
Hi,

I need to change the type of my photos from jpg to tiff. I found this piece of code from Alexey on the forums to do this:

Code: [Select]
chunk = PhotoScan.app.document.activeChunk
for i in range (len(chunk.cameras)):
    chunk.cameras[i].frames[0].path = chunk.cameras[i].path.replace(".jpg", ".tiff")

Can I paste this code in the console or run it directly as a script? I'm getting a bunch of different syntax errors. Any help would be appreciated; I'm completely new to Python.

Thanks!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15282
    • View Profile
Re: Change image file type
« Reply #1 on: August 08, 2016, 09:36:50 AM »
Hello,

For the latest version of PhotoScan Pro I suggest to use the following script (saved as .py file and executed from Run Script dialog):
Code: [Select]
import PhotoScan
chunk = PhotoScan.app.document.chunk
suffix = "tiff"
for camera in chunk.cameras:
camera.label = ".".join([camera.label.rsplit(".",1)[0], suffix])
camera.photo.path = ".".join([camera.photo.path.rsplit(".",1)[0], suffix])
this script swaps the extension for the cameras from the existing to "tiff", but you can change it in the script body to any other.
Best regards,
Alexey Pasumansky,
Agisoft LLC