Shiny Language Reference
Language Reference > Image Functions
saveimagejpg
bool saveimagejpg(image MyImage, string Filename, int Quality);
Saves the specified image to a file
Experimental. The SAVEIMAGEJPG statement saves the specified image to the specified filename in JPEG format (*.jpg). This statement has been included for future expansion of the Shiny language however is available for use immediately. An example use could be to load an image, rotate and scale it, then use this statement to save it back to disk.
Note that you are responsible for naming the file correctly, i.e.: with a ".jpg" extension. You may name the file anything you like, but the image will always be saved in a compressed JPEG format. For uncompressed formats, refer to saveimagebmp. The JPG format only supports 24bit images. To save a 32bit image (an image with per-pixel alpha values) refer to saveimagepng.
Although this statement is experimental, plugin developers can take advantage of it immediately. Any changes to the operation of this statement will not affect any plugins that use it.
Parameters
MyImage
A variable declared as type IMAGE and previously associated with a bitmap image using the CREATEIMAGE statement.
Filename
The path and filename to save the image to. You are responsible for validating this value, as well as providing a .jpg extension.
Quality
The JPG format is a lossy compression format. This means that high compression (low filesizes) is achieved by dropping (losing) some information from the image, which alters the image quality. You may specify the image quality to use for your saved file. Filesize increases as quality increases. You will normally want to use JPEG_QUALITYGOOD or JPEG_QUALITYNORMAL. The following variables are already defined internally within SSEdit and the Shiny compiler:
Internal definition Value Result JPEG_QUALITYSUPERB 0x00000080 Highest quality, largest filesize JPEG_QUALITYGOOD 0x00000100 Above average quality, larger filesize JPEG_QUALITYNORMAL 0x00000200 Normal quality produced by paint packages, medium filesize JPEG_QUALITYAVERAGE 0x00000400 Lower than normal quality, small filesize JPEG_QUALITYBAD 0x00000800 Lowest quality (visibly poor), smallest filesize
Return Value
True if saving succeeded, otherwise False. Saving can fail in limited circumstances, for example when the image format is incompatible with the JPG filetype, or the specified path and filename is invalid. At this time further behaviour is undefined as this feature is experimental.
Example Code
image MyImage;
if(createimage(MyImage, "C:\\MyBitmap.bmp") == TRUE)
{
// Invert the image
invertimage(MyImage);
// Save it back to disk as a jpeg
saveimagejpg(MyImage, "C:\\MyBitmapInverted.jpg");
}