indus / kubi

a fast and flexible cubemap generator
MIT License
53 stars 15 forks source link

Trouble passing -co arguments #12

Closed claytonrothschild closed 1 year ago

claytonrothschild commented 1 year ago

Great library, thank you.

When I pass co arguments on linux and mac, Pyvips fails. Mac and linux.

Any tips greatly appreciated.

kubi -r lbb -f nx px py ny nz pz test.jpg test_out.jpg -co overlap=0

Traceback (most recent call last):
  File "/usr/local/bin/kubi", line 33, in <module>
    sys.exit(load_entry_point('kubi', 'console_scripts', 'kubi')())
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 343, in run
    main(sys.argv[1:])
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 339, in main
    kubi(args)
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 225, in kubi
    mapim.write_to_file(f'{dst}_{fn}{dst_ext}', **args.co)
  File "/usr/local/lib/python3.9/site-packages/pyvips/vimage.py", line 804, in write_to_file
    return pyvips.Operation.call(name, self, filename,
  File "/usr/local/lib/python3.9/site-packages/pyvips/voperation.py", line 288, in call
    raise Error('{0} does not support optional argument {1}'
pyvips.error.Error: VipsForeignSaveJpegFile does not support optional argument overlap

kubi -r lbb -f nx px py ny nz pz test.jpg test_out.jpg -co jpg

Traceback (most recent call last):
  File "/usr/local/bin/kubi", line 33, in <module>
    sys.exit(load_entry_point('kubi', 'console_scripts', 'kubi')())
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 343, in run
    main(sys.argv[1:])
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 339, in main
    kubi(args)
  File "/usr/local/lib/python3.9/site-packages/kubi/kubi.py", line 225, in kubi
    mapim.write_to_file(f'{dst}_{fn}{dst_ext}', **args.co)
  File "/usr/local/lib/python3.9/site-packages/pyvips/vimage.py", line 804, in write_to_file
    return pyvips.Operation.call(name, self, filename,
  File "/usr/local/lib/python3.9/site-packages/pyvips/voperation.py", line 288, in call
    raise Error('{0} does not support optional argument {1}'
pyvips.error.Error: VipsForeignSaveJpegFile does not support optional argument compression
indus commented 1 year ago

Havn't looked into this but maybe it helps to move the -co before the input and output?!

indus commented 1 year ago

Oh wait, I think it clearly says what the problem is; those options are not available when you save the output as jpeg. compression is available for Tiffs for example (you can use JPEG compression in a Tiff or LZW, DEFLATE, etc.; FYI: https://libvips.github.io/pyvips/enums.html#pyvips.enums.ForeignTiffCompression). The overlap option is only available for deepzoom (.dz) image pyramids. So I would say the errors are correct.

indus commented 1 year ago

Here is a list of the options for jpegsave (Parameters): https://libvips.github.io/pyvips/vimage.html#pyvips.Image.jpegsave Maybe you wanted "Q" for quality (-co Q=75)? The options you are using are from https://libvips.github.io/pyvips/vimage.html#pyvips.Image.dzsave

indus commented 1 year ago

@claytonrothschild Were you able to solve the problems and generate the desired output with kubi? Should I close this?

claytonrothschild commented 1 year ago

The solution is that indeed the -co arguments fail if one is not generating an image pyramid (dzsave) - as those arguments are specific to image pyramid.

Details here

So for example, this will fail:

kubi -r lbb -f nx px py ny nz pz test.jpg test_out.jpg -co overlap=0

but this will succeed no problem:

kubi -r lbb -f nx px py ny nz pz test.jpg test_out.dz -co overlap=0

We can close this!