def create_jp2(img_name, img_id):
image = Image.open('{}.tiff'.format(img_name))
if image.mode == 'RGB':
kdu_com = kdu_command_rgb.format(img_name, img_name)
else:
kdu_com = kdu_command.format(img_name, img_name)
kdu_com = kdu_com.replace('{', '\{')
kdu_com = kdu_com.replace('}', '\}')
res = subprocess.getoutput(kdu_com)
if res.startswith('Kakadu Error'):
# Probably not uncompressed tiff
print('probably not uncompressed tiff')
print(res)
subprocess.getoutput('mv {}.tiff {}-2.tiff'.format(img_name, img_name))
subprocess.getoutput(convert_command.format(img_name, img_name))
kdu_com2 = kdu_command.format(img_name, img_name)
kdu_com2 = kdu_com2.replace('{', '\{')
kdu_com2 = kdu_com2.replace('}', '\}')
res = subprocess.getoutput(kdu_com2)
print('new response')
print(res)
if res.startswith('Kakadu Error') or res.startswith('Kakadu Core Error'):
print('Still broken :(')
raise ValueError(img_name)
k = Key(b, '{}{}.jp2'.format(image_base, img_id))
k.set_contents_from_filename('{}.jp2'.format(img_name))
评论列表
文章目录