def db_get_image_info(fsp):
	"""get_image_info(path)

Takes a bdb: specifier and returns the number of images and image dimensions."""
	if fsp[:4].lower()=="bdb:" :
		path,dictname,keys=db_parse_path(fsp)
		if keys==None :
			# This dictionary contains image counts for the others in this directory
			db2=db_open_dict("bdb:%s#%s"%(path,"00image_counts"))

			# If this is true, we need to update the dictionary
			if (db2.has_key(dictname) and os.path.getmtime("%s/EMAN2DB/%s.bdb"%(path,dictname))>db2[dictname][0]) or not db2.has_key(dictname) or db2[dictname][2][0]==0:
#				print "update ",dictname,os.path.getmtime("%s/EMAN2DB/%s.bdb"%(path,dictname)),db2[dictname][0],db2.has_key(dictname)
				db=db_open_dict(fsp,True)
				try:
					im=db[0]
					sz=(im["nx"],im["ny"],im["nz"])
				except :
					sz=(0,0,0)
				db2[dictname]=(time.time(),len(db),sz)

			return db2[dictname][1:]

		else :			# if the user specifies the key in fsp, we ignore parms
			db=db_open_dict(fsp,True)
			n=0
			for i in keys:
				if i in db : n+=1
			sz=db[keys[0]]
			sz=(sz["nx"],sz["ny"],sz["nz"])
			return (n,sz)
	img=EMData(fsp,0,True)
	return (EMUtil.get_image_count_c(fsp),(img["nx"],img["ny"],img["nz"]))
def db_get_image_count(fsp):
	"""get_image_count(path)

Takes a path or bdb: specifier and returns the number of images in the referenced stack."""
	if fsp[:4].lower()=="bdb:" :
		path,dictname,keys=db_parse_path(fsp)
		if keys==None :
			# This dictionary contains image counts for the others in this directory
			db2=db_open_dict("bdb:%s#%s"%(path,"00image_counts"))

			# If this is true, we need to update the dictionary
			if (db2.has_key(dictname) and os.path.getmtime("%s/EMAN2DB/%s.bdb"%(path,dictname))>db2[dictname][0]) or not db2.has_key(dictname) :
				db=db_open_dict(fsp,True)
				try:
					im=db[0]
					sz=(im["nx"],im["ny"],im["nz"])
				except : sz=(0,0,0)
				db2[dictname]=(time.time(),len(db),sz)

			return db2[dictname][1]

		else :			# if the user specifies the key in fsp, we ignore parms
			db=db_open_dict(fsp,True)
			n=0
			for i in keys:
				if i in db : n+=1
			return n

	return EMUtil.get_image_count_c(fsp)