Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - FreeArt

Pages: [1]
1
Python and Java API / Re: add photo and save project
« on: August 26, 2015, 03:21:21 PM »
Hello Alexey,

Thanks your hint, the problem was little strange for me:

if I use this:

Code: [Select]
if ("tiff" or "tif") in photo.lower():

The program don't add tif photos.

But if I use this line:

Code: [Select]
if ("tif" or "tiff") in photo.lower():

The program add tif files for chunk.

But Now the program works fine
and Really thanks your and James help  :).

here is the complet code:

Code: [Select]

import os
import PhotoScan

global doc
doc = PhotoScan.app.document

#path to photos
path_photos = PhotoScan.app.getExistingDirectory("Specify input photo folder:")

print("Script started")

#creating new chunk
doc.addChunk()
chunk = doc.chunks[-1]
chunk.label = "New Chunk"

project_path = PhotoScan.app.getSaveFileName("Specify project filename for saving:")
if not project_path:
print("Script aborted")

if project_path[-4:].lower() != ".psz":
project_path += ".psz"

#loading images
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
if ("tif" or "tiff") in photo.lower():
photo_list.append(path_photos + "\\" + photo)
chunk.addPhotos(photo_list)
doc.save(project_path)
PhotoScan.app.update()
print("Script finished")


Regards
Peter

2
Python and Java API / Re: add photo and save project
« on: August 26, 2015, 11:04:02 AM »
Thanks James for your reply.
 
I fixed my stupid mistake but unfortunately the program isn't work fine, because the program isn't save the project and can't add my tif photos BUT if I switch tif argument to "jpg" or "jpeg" the program can add jpg photos for chunk.
But It would be better if the program could add tiff photos for chunk. Can you give me some hint?

many Thanks

Peter

3
Python and Java API / add photo and save project
« on: August 25, 2015, 10:36:29 PM »
Hello

I'm using photoscan 1.1.6 and I wrote one little script which open and add all .tif photo from one directory and save this project to .psz but unfortunately the script is not work because can't open and add photos for chunk and I don't know why.

The error code:

    if proejct_path[-4:].lower() != ".psz":
NameError: name 'proejct_path' is not defined

The script:
Code: [Select]

import os
import PhotoScan

global doc
doc = PhotoScan.app.document

#path to photos
path_photos = PhotoScan.app.getExistingDirectory("Specify input photo folder:")

print("Script started")

#creating new chunk
doc.addChunk()
chunk = doc.chunks[-1]
chunk.label = "New Chunk"

project_path = PhotoScan.app.getSaveFileName("Specify project filename for saving:")
if not project_path:
print("Script aborted")

if proejct_path[-4:].lower() != ".psz":
project_path += ".psz"

#loading images
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
if ("TIFF" or "tif") in photo.lower():
photo_list.append(path_photos + "\\" + photo)
chunk.addPhotos(photo_list)
doc.save()
PhotoScan.app.update()
print("Script finished")


I would appreciate any help doing this. Thanks and sorry my poor English.

Regards
Peter

Pages: [1]