Permalink
Browse files

Filenames in TrakEM2 project are fixed.

  • Loading branch information...
perlman committed Aug 7, 2011
1 parent c0c5eb0 commit 830d3e54513504e75b954e9765c4b900a02d5cb7
Showing with 23 additions and 11 deletions.
  1. +10 −7 utility/crop.py
  2. +13 −4 utility/trakxml.py
View
@@ -250,21 +250,24 @@ def main():
if args.crop:
img = img.crop(tuple(args.crop))
- outfile = None
+ outfilename = None
+ outfilepath = None
fileformat = args.format.lower()
if (fileformat == "png"):
- outfile = "{0}/{1}.png".format(args.outdir, slice)
- img.save(outfile, format="PNG", optimize=1)
+ outfilename = "{1}.png".format(args.outdir, slice)
+ outfilepath = "{0}/{1}".format(args.outdir, outfilename)
+ img.save(outfilepath, format="PNG", optimize=1)
elif (fileformat == "jpg" or fileformat == "jpeg"):
- outfile = "{0}/{1}.jpg".format(args.outdir, slice)
- img.save(outfile, format="JPEG", quality=args.quality)
+ outfilename = "{1}.jpg".format(args.outdir, slice)
+ outfilepath = "{0}/{1}".format(args.outdir, outfilename)
+ img.save(outfilepath, format="JPEG", quality=args.quality)
else:
print "Invalid format: {0}".format(fileformat)
- print outfile
+ print outfilepath
if args.trakem2:
- trak.writeLayer(trakfd, slice, outfile, outHeight, outWidth)
+ trak.writeLayer(trakfd, slice, outfilename, outHeight, outWidth)
if args.trakem2:
trak.writeFooter(trakfd)
View
@@ -1,8 +1,12 @@
#!/usr/bin/python
+import random
+
class TrakXML:
def __init__(self):
+ random.seed()
self.oid = 0
+ self.unuid = "{0}.{1}.{2}".format(random.randint(0,100000000000), random.randint(0,100000000), random.randint(0,100000000))
def getoid(self):
self.oid = self.oid + 1
@@ -270,16 +274,21 @@ def writeBody(self, file, height, width):
<trakem2>
<project
id="0"
- title="CATMAID Clip"
- unuid="1303262609289.1052629572.95381466"
+ title="CATMAID Crop (experimental)"
+""")
+ file.write('unuid="{0}"\n'.format(self.unuid))
+ file.write("""
storage_folder=""
image_resizing_mode="Gaussian"
look_ahead_cache="0"
n_undo_steps="32"
+ layer_mipmaps="true"
>
</project>
<t2_layer_set
- oid="3"
+""")
+ file.write('oid="{0}"\n'.format(self.getoid()))
+ file.write("""
width="20.0"
height="20.0"
transform="matrix(1.0,0.0,0.0,1.0,0.0,0.0)"
@@ -329,7 +338,7 @@ def writeLayer(self, file, layer, filename, height, width):
file.write('transform="matrix(1.0,0.0,0.0,1.0,0,0)"\n')
file.write('style="fill-opacity:1.0;stroke:#ffff00;"\n')
file.write('min="0" max="255"\n')
- file.write('title="{0}\n'.format(filename))
+ file.write('title="{0}"\n'.format(filename))
file.write('links=""\n')
file.write('type="0"\n')
#print 'file_path="http://openconnectomeproject.org/data/misc/nodata.png"'

0 comments on commit 830d3e5

Please sign in to comment.