---
title: "JpegWriter Class"
canonical: https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_JpegWriter.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# JpegWriter Class
 
This class enables you to write JPEG images.
 
**Namespace:** [Aurigma.GraphicsMill.Codecs](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
 **Assembly:** Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
 
## Syntax
  
```
Public NotInheritable Class JpegWriter _Inherits FormatWriter _Implements IMetadataWriteSupport
```
 
```csharp
public sealed class JpegWriter : FormatWriter, IMetadataWriteSupport
```
 
## Remarks
  
JPEG is a standard image format for storing photos. JPEG stands for Joint Photographic Experts Group, the original name of the committee that wrote this standard. JPEG stores images with lossy compression and it is designed for compressing either full-color or grayscale images of natural, real-world scenes. During the process of an original image writing to JPEG the quality of image can be specified. The less compression quality specified, the less size result file will have.
 
There is a special type of JPEG images - progressive. Progressive JPEG rearranges the stored image data. When the JPEG file is transmitted across a slow communications link, it allows to decoder to generate a low-quality image very quickly, then gradually improve the displayed quality as more image data are received. The final image is identical to that of a regular JPEG file of the same quality setting.
 
JPEG files can also contain XMP, EXIF, IPTC data and Adobe® image resource blocks. However it does not support multiple images in the single file.
 
JPEG images support three main color spaces:
 
- RGB;
- CMYK;
- Grayscale;

It does not support indexed images, as well as extended (16 bit per channel) pixel formats.
 
## Examples
  
You can use JpegWriter class instead of the [Save(String, IEncoderOptions)](https://www.graphicsmill.com/docs/gm5/M_Aurigma_GraphicsMill_Bitmap_Save_2_b73a8298.htm.md) method of the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md). In particular it enables you to save the image asynchronously.
 
The JpegWriter class usage is demonstrated below:
 
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg")

Dim writer As New Aurigma.GraphicsMill.Codecs.JpegWriter("C:\Mountain2.jpg")

Dim frame As New Aurigma.GraphicsMill.Codecs.JpegFrame
frame.Quality = 50
frame.IsProgressive = True
frame.SetBitmap(bitmap)

bitmap.Dispose()

writer.AddFrame(frame)

frame.Dispose()

writer.Dispose()
```
 
```csharp
using (Aurigma.GraphicsMill.Bitmap bitmap = 
        new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg"))
{
    using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = 
            new Aurigma.GraphicsMill.Codecs.JpegWriter(@"C:\Mountain2.jpg"))
    {

        using (Aurigma.GraphicsMill.Codecs.JpegFrame frame = 
                   new Aurigma.GraphicsMill.Codecs.JpegFrame())
        {
            frame.Quality = 50;
            frame.IsProgressive = true;
            frame.SetBitmap(bitmap);

            writer.AddFrame(frame);                
        }

    }
}
```
 
JPEG files can store XMP, EXIF, IPTC data blocks and Adobe® image resource blocks. Graphics Mill for .NET allows you extracting this data from the JPEG file and save it into another JPEG file (as well as into the other file format which supports corresponding meta information). This code sample demonstrates how to add the EXIF and IPTC data to the file:
 
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg")

Dim writer As New Aurigma.GraphicsMill.Codecs.JpegWriter("C:\Mountain2.jpg")

'EXIF
Dim exif As New Aurigma.GraphicsMill.Codecs.ExifDictionary
exif(Aurigma.GraphicsMill.Codecs.ExifDictionary.Software) = "Aurigma Graphics Mill"

writer.Exif = exif

'IPTC
Dim iptc As New Aurigma.GraphicsMill.Codecs.IptcDictionary
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.Category) = "Nature"
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.CopyrightNotice) = "Aurigma Inc."
iptc(Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword) = "mountain"

writer.Iptc = iptc

'Adobe resource blocks
Dim adobeResources As New Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary
'Create new adobe image resource block with the required metadata
Dim arBlock As New Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", New Byte() {1})
'Set this block to the item with 0x040A ID (copyright flag)
adobeResources.Item(&H40A) = arBlock

writer.AdobeResources = adobeResources

'XMP
Dim xmp As New Aurigma.GraphicsMill.Codecs.XmpData()
'Create a node with the required metadata
Dim node As New Aurigma.GraphicsMill.Codecs.XmpValueNode( _
    Aurigma.GraphicsMill.Codecs.XmpNodeType.SimpleProperty, _
    "John Doe", _
    Aurigma.GraphicsMill.Codecs.XmpTagNames.DCCreator)
xmp.AddNode(node)

writer.Xmp = xmp.Save()

Dim frame As New Aurigma.GraphicsMill.Codecs.JpegFrame(50, True)

frame.SetBitmap(bitmap)

bitmap.Dispose()

writer.AddFrame(frame)

frame.Dispose()

writer.Dispose()
```
 
```csharp
using (Aurigma.GraphicsMill.Bitmap bitmap = 
           new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg"))
{                
    using (Aurigma.GraphicsMill.Codecs.JpegWriter writer = 
               new Aurigma.GraphicsMill.Codecs.JpegWriter(@"C:\Mountain2.jpg"))
    {
        //EXIF
        Aurigma.GraphicsMill.Codecs.ExifDictionary exif =
            new Aurigma.GraphicsMill.Codecs.ExifDictionary();
        exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Software] = "Aurigma Graphics Mill";

        writer.Exif = exif;
    
        //IPTC
        Aurigma.GraphicsMill.Codecs.IptcDictionary iptc =
            new Aurigma.GraphicsMill.Codecs.IptcDictionary();
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Category] = "Nature";
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.CopyrightNotice] = "Aurigma Inc.";
        iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword] = "mountain";

        writer.Iptc = iptc;

        //Adobe resource blocks
        Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary adobeResources =
            new Aurigma.GraphicsMill.Codecs.AdobeResourceDictionary();
        //Create new adobe image resource block with the required metadata
        Aurigma.GraphicsMill.Codecs.AdobeResourceBlock arBlock = new
            Aurigma.GraphicsMill.Codecs.AdobeResourceBlock("Copyright", new byte[] { 1 });
        //Set this block to the item with 0x040A ID (copyright flag)
        adobeResources[0x040A] = arBlock;

        writer.AdobeResources = adobeResources;

        //XMP
        Aurigma.GraphicsMill.Codecs.XmpData xmp = new Aurigma.GraphicsMill.Codecs.XmpData();
        //Create a node with the required metadata
        Aurigma.GraphicsMill.Codecs.XmpValueNode node = new
            Aurigma.GraphicsMill.Codecs.XmpValueNode(
                Aurigma.GraphicsMill.Codecs.XmpNodeType.SimpleProperty,
                "John Doe",
                Aurigma.GraphicsMill.Codecs.XmpTagNames.DCCreator);
        xmp.AddNode(node);

        writer.Xmp = xmp.Save();

        using (Aurigma.GraphicsMill.Codecs.JpegFrame frame = 
                   new Aurigma.GraphicsMill.Codecs.JpegFrame(50, true))
        {
            frame.SetBitmap(bitmap);

            writer.AddFrame(frame);
        }
    }
}
```
 
## Inheritance Hierarchy
  
- [System.Object](http://msdn2.microsoft.com/en-us/e5kfa45b)
    - [Aurigma.GraphicsMill.SyncHandler](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_SyncHandler.htm.md)
        - [Aurigma.GraphicsMill.Codecs.FormatWriter](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_FormatWriter.htm.md)
            - Aurigma.GraphicsMill.Codecs.JpegWriter
 
## Thread Safety
 Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
 
## Object Model

[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_143.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_JpegWriter.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_4.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_AdobeResourceDictionary.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_5.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_ExifDictionary.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_107.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IEncoderOptions.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel2.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_108.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IFrame.htm.md)
![](https://www.graphicsmill.com/docs/gm5/ObjectModel1.png)[![](https://www.graphicsmill.com/docs/gm5/Aurigma.GraphicsMill_ObjectModel_6.png)](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_IptcDictionary.htm.md)
 
## Supported Pixel Formats

| Member Name | Description |
| --- | --- |
| **Format8bppGrayScale** | 8 bits per pixel. Grayscale. 8 bits are used for luminosity level. |
| **Format24bppRgb** | 24 bits per pixel. RGB. 8 bits each are used for the red, green, and blue components. |
| **Format32bppCmyk** | 32 bits per pixel. CMYK. 8 bits each are used for the cyan, magenta, yellow, and black components. |
 
## See Also

### Reference

- [JpegWriter Members](https://www.graphicsmill.com/docs/gm5/AllMembers_T_Aurigma_GraphicsMill_Codecs_JpegWriter.htm.md)
- [Aurigma.GraphicsMill.Codecs Namespace](https://www.graphicsmill.com/docs/gm5/N_Aurigma_GraphicsMill_Codecs.htm.md)
