To zoom up to the reason for all of this:
I Wrote a workflow for placing your own (or other's) astroimages in to the planetarium program Stellarium, so that when you zoom into a DSO in the planetarium you see your artwork, vs. the default, or lack of an image that ships with Stellarium (and all the stars line up).
FYI, that workflow is described in chapter 8 of the Stellarium documentation.
That workflow uses astropy to solve images via nova.
But now, I have one image that simply refuses to solve on nova, M11, despite manipulating the levels etc. I also had trouble getting to solve in PI, until I switched from Polygons to Triangle Similarity (why would an open cluster be "hard" to solve when globs solve just fine?).
Anyway my hope was to use PI to generate the data such that I could insert it back into my workflow to get the corners of the image in WCS coordinates.
Since the workflow works with finished astroimages ("un-stretching" them by raising the black point for solving) it doesn't really use fits files for anything. Usually you have a jpeg, and stellarium wants a PNG (where up = North and the sides are wither 512, 1024, or 2048 pixels).
First it creates a jpg version of the image with the black point raised so hopefully only stars are visible, then this is solved to figure out the angle on the sky of the original image (I've noticed that nova is more successful solving jpegs than pngs of the same image).
Next the image is rotated so up is north, and the edges filled in with black. Then it resizes and crops the image so the sides are multiples of 512 and saves the image as a png.
Lastly, it ("un-stretches" and) solves that final rotated, resized, and cropped image, to find the corners of the image in WCS coordinates, and prints them in a JSON format for inclusion in Stellearium's textures.json file of nebula artwork.
So, again, I don't really need fits file format an any point. It's just a format that astropy understands with fits headers. I do see a post here:
Hi. I'm writing a Python-based decoder for XISF files (as property dicts and Numpy arrays for use in the many Python-based astronomy tools out there) and have a few questions about the format as it is being currently used in P. First, let me say the format is an extremely good one having...
pixinsight.com
that suggests xisf support was being added to astropy, but it doesn't look like that ever happened?
I guess the other thing that would be helpful would be an API to call the PI solver from astropy, avoiding file formats altogether.
But in any case given that the source images in question are jpegs and not fits, can we agree that the PI solve data is incorrect (or is at least incompatible with astropy because PI assumes a different standard for writing fits files than astropy expects?)?
and/or is there a solution to modify the image before solving in PI and is it flipping both horizontally and vertically (I will experiment more I guess)?