Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

full list of simple_image image types #1345

Closed
raybellwaves opened this issue Sep 5, 2020 · 3 comments
Closed

full list of simple_image image types #1345

raybellwaves opened this issue Sep 5, 2020 · 3 comments

Comments

@raybellwaves
Copy link
Contributor

raybellwaves commented Sep 5, 2020

Curious how easy (hard) it would be to add the full list of image types that simple_image provides.

When running

from satpy import available_writers
available_writers()

I see ['mitiff', 'cf', 'simple_image', 'geotiff', 'scmi']. I believe what I was after was as a list of image formats I can provide when using scn.save_dataset e.g. png as doing scn2.save_dataset('true_color', filename='test') returns

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/trollimage/image.py in check_image_format(fformat)
     81     try:
---> 82         fformat = cases[fformat]
     83     except KeyError:

KeyError: ''

During handling of the above exception, another exception occurred:

UnknownImageFormat                        Traceback (most recent call last)
<ipython-input-12-7b813b2b856c> in <module>
      1 #scn2.show('true_color')
----> 2 scn2.save_dataset('true_color', filename='test')

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/satpy/scene.py in save_dataset(self, dataset_id, filename, writer, overlay, decorate, compute, **kwargs)
   1302                                           filename=filename,
   1303                                           **kwargs)
-> 1304         return writer.save_dataset(self[dataset_id],
   1305                                    overlay=overlay, decorate=decorate,
   1306                                    compute=compute, **save_kwargs)

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/satpy/writers/__init__.py in save_dataset(self, dataset, filename, fill_value, overlay, decorate, compute, **kwargs)
    827         img = get_enhanced_image(dataset.squeeze(), enhance=self.enhancer, overlay=overlay,
    828                                  decorate=decorate, fill_value=fill_value)
--> 829         return self.save_image(img, filename=filename, compute=compute, fill_value=fill_value, **kwargs)
    830 
    831     def save_image(self, img, filename=None, compute=True, **kwargs):

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/satpy/writers/simple_image.py in save_image(self, img, filename, compute, **kwargs)
     63 
     64         LOG.debug("Saving to image: %s", filename)
---> 65         return img.save(filename, compute=compute, **kwargs)

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/trollimage/xrimage.py in save(self, filename, fformat, fill_value, compute, keep_palette, cmap, **format_kwargs)
    422                                  **format_kwargs)
    423         else:
--> 424             return self.pil_save(filename, fformat, fill_value,
    425                                  compute=compute, **format_kwargs)
    426 

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/trollimage/xrimage.py in pil_save(self, filename, fformat, fill_value, compute, **format_kwargs)
    608         """
    609         fformat = fformat or os.path.splitext(filename)[1][1:]
--> 610         fformat = check_image_format(fformat)
    611 
    612         if fformat == 'png':

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/trollimage/image.py in check_image_format(fformat)
     82         fformat = cases[fformat]
     83     except KeyError:
---> 84         raise UnknownImageFormat("Unknown image format '%s'." % fformat)
     85     return fformat
     86 

UnknownImageFormat: Unknown image format ''.

In that error message I saw if fformat == 'png' so I ended up going for that first time round.

@djhoese
Copy link
Member

djhoese commented Sep 5, 2020

Very good points. The issue for why this doesn't exist is that these available formats come from PIL (the python image library) and I think what formats can be used inevitably depend on how your installed version of PIL was built. @mraspaud maybe we could provide some of the standard ones and then link to PIL's documentation? Or maybe PIL has a way of listing them?

@djhoese
Copy link
Member

djhoese commented Sep 5, 2020

Based on this page we should probably just list jpeg and png and then link to the page: https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html

@mraspaud
Copy link
Member

Closed through pytroll/trollimage#88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants