AstroPhoto-Plus icon indicating copy to clipboard operation
AstroPhoto-Plus copied to clipboard

Option to save jpg format in Sequence capture?

Open universe241981 opened this issue 6 years ago • 11 comments

Is that possible to add an option to save the sequence captured images in jpg format?

Thanks.

universe241981 avatar Mar 12 '19 02:03 universe241981

Hi, Yes, it is possible, and actually there's already some code doing this in the backend (for previewing into the app).

However this code only converts the preexisting FITS file, so we would always need FITS at least at first, so I guess we should hook into the sequencing module, and add an option to convert the FITS file, and then delete it We would need to implement some sort of UI to configure this feature too.

It's not too complicated obviously, but I would argue that for now I would prioritise other features over this. It's still a valid request for a feature implementation though :)

GuLinux avatar Mar 14 '19 16:03 GuLinux

Thank you very much on your respond on this feature. I've try to look at the "image processing" folder in the "backend" folder. But found no idea how I could just extract your image processing code out from the backend and do image processing so that I can have jpg image converted from fits. Perhaps you can guide me a little bit? The jpg file that I required is just for preview purpose, just like the preview image shown at the "camera" section or the "Sequence" section about "show the last captured image". Thank you very much once again.

universe241981 avatar Mar 15 '19 01:03 universe241981

Mmmh, it depends. If you just wish to patch AstroPhoto Plus for yourself, then it might be quite easy. When you open backend/sequences/exposure_sequence_job.py, around line 119, you'll see the following code:

        def on_each_saved(job_runner, index, filename):
            logger.info('received file for index {}: {}'.format(index, filename))

            image = Image(path=filename, file_required=True)
            self.progress = job_runner.finished

you just need to add, after initialising the image variable, something like this:

           image.convert({ 'format': 'jpeg', 'stretch': '1' })

If you want to submit a patch, it's obviously gonna be a bit more tricky, and you'd have to create a frontend UI to toggle this as a flag, and set the various saving options.

GuLinux avatar Mar 16 '19 18:03 GuLinux

Hi, Thank you very much on your guidance.

Basically, I just wish to patch AstroPhoto-Plus in order to have a jpg image being converted automatically whenever a fits image being captured. The jpg image no need to be in full resolution as the fits image. Perhaps 1024x768 is good enough. Then, I can have a separate webpage to show the jpg image through the internet.

Anyway, I would like to express my gratitude to you. You have written a good program.

universe241981 avatar Mar 18 '19 02:03 universe241981

Hi, Thank you very much on your guidance.

Basically, I just wish to patch AstroPhoto-Plus in order to have a jpg image being converted automatically whenever a fits image being captured. The jpg image no need to be in full resolution as the fits image. Perhaps 1024x768 is good enough. Then, I can have a separate webpage to show the jpg image through the internet.

Then you can also append the maxwidth parameter in order to automatically apply scaling:

           image.convert({ 'format': 'jpeg', 'stretch': '1', 'maxwidth': 1024 })

Anyway, I would like to express my gratitude to you. You have written a good program. Thank you, I really appreciate my apps being of help of course :)

Cheers, Marco

GuLinux avatar Mar 18 '19 10:03 GuLinux

Thank you very much once again.

I think I forgot to ask another related question. I have b644 installed in my RPi. How can I access to the exposure_sequence_job.py to patch the code as mentioned above?

Thank you.

universe241981 avatar Mar 18 '19 15:03 universe241981

Hi, sorry, what's b644? Anyway the file is in /usr/lib/AstroPhotoPlus/backend/sequences/exposure_sequence_job.py

GuLinux avatar Mar 18 '19 15:03 GuLinux

Hi Marco, You are a genius or some kind? I have added the code you provided above and it works! Thank you so much on your kindness!

Sorry that if I asked too much...how could I rename the converted jpg filename in some sort of sequence? Is there any ways? As of currently, the filename has two groups of alphabets & numbers. The alphabets & numbers of the later group is fix and the leading group is random.

By the way, the b644 refer to your build version.

Thank you very much.

universe241981 avatar Mar 19 '19 01:03 universe241981

Hi, the image conversion is meant for preview only, that is why I never implemented a way to save to a different filename, but using the internal ID for it. Anyway, you can always rename the file after creating it, changing the code into this:

preview_info = image.convert({ 'format': 'jpeg', 'stretch': '1', 'maxwidth': 1024 })
os.rename(preview_info['path'], filename + '.jpg')

GuLinux avatar Mar 19 '19 09:03 GuLinux

Hi, After implemented your codes above, I have now the jpg files automatically converted from the fits files and renamed it automatically with the same filename as the fits.

I also created a php page to show the latest captured converted jpg image and refresh every 60 secs. After several test, it seem quite a stable.

I am using your AstroPhoto Plus on Pi0W. With the indi_qhy driver been downgraded to version 1.6. Otherwise the Pi0W won't connect to the qhy indi driver.

P.S: BTW, I would like to suggest you to let the AstroPhoto Plus has an option to support the INDIGO server. It seem relatively stable compared to INDI. You may have a look on INDIGO.

universe241981 avatar Mar 26 '19 15:03 universe241981

Cool :) Yes, I did look into INDIGO, and it might actually be interesting as it support JSON API natively. In theory they should really be exchangeable, as the XML protocol is the same. Problem is it doesn't have an Astrometry driver, so at the moment is out of scope. As soon as I implement a different plate solving solution (which is planned, but on low priority) I will start looking into INDIGO more closely

GuLinux avatar Mar 28 '19 11:03 GuLinux