# JPEG Images on SkyServer

The Visual Tools section of Skyserver – which includes the Finding Chart, Navigate, Image Lists pages and the postage stamp image displayed on the Explore page for each object – uses JPEG versions of the SDSS images that are retrieved and constructed on the fly by the ImgCutout web service by querying the Catalog Archive Server (CAS) databases for the given data release.

In order to create the base JPEG images that are then stored in multiple zoom levels (resolutions) in the CAS databases, the FITS2JPEG converter – a MATLAB code – reads in the gr, i-band FITS corrected frame files from the Science Archive Server (SAS) and performs a number of transformations on them before converting them to 3-color JPEG images (i-r-g to R-G-B), as described in the FITS to JPEG conversion data flow diagram shown below. Multiple “zoom levels” or resolutions are generated for each image, facilitating zooming in and out in the visual tools interface.  Images are interpolated between the preset zoom levels. The conversion is based upon an algorithm described in Lupton et al. (2004), with some modifications.

In the CAS database, image frames are stored in the Frame table according to their fieldIDs and zoom levels, along with photometry and run, rerun, camcol parameters. When a user asks for an image cutout for the given coordinates on the sky with the desired dimensions, the ImgCutout service first parses the request and figures out the scale needed to query images from the database.  Using the given coordinates and scale, a SQL function is invoked in the database that zeroes in on the frames that contain the given part of the sky.  ImgCutout then uses these frames to draw the image upon the canvas using the affine transform. Since these are the whole SDSS frames attached to each other (i.e., mosaicked) and the user usually wants a piece of the total area covered by the frames, the final image displayed is trimmed to the given width and height with the requested coordinate at the center. When the user selects certain overlay options, for example to highlight Photo Objects or Spec Objects or to draw SDSS fields, a separate set of queries is run along with the original image query. These queries return a list of objects with coordinates. These co-ordinates are used to draw distinct markers for various objects on the underlying image, as requested by user.