Struct MediaSize
Represents a media size for images and videos with predefined presets for various AI models and social media platforms. Supports DALL-E, GPT Image, Sora, and common social media formats.
Inherited Members
Namespace: Glitch9.AIDevKit
Assembly: Glitch9.AIDevKit.dll
Syntax
[Serializable]
public readonly struct MediaSize : IStringWrapper, IEquatable<MediaSize>
Constructors
| Edit this page View SourceMediaSize(int, int)
Creates a new MediaSize from width and height dimensions
Declaration
public MediaSize(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | Width in pixels |
| int | height | Height in pixels |
MediaSize(string)
Creates a new MediaSize with the specified size string
Declaration
public MediaSize(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | Size string (e.g., "1024x1024", "auto") |
Fields
| Edit this page View SourceAuto
Automatic size selection by the AI model
Declaration
public const string Auto = "auto"
Field Value
| Type | Description |
|---|---|
| string |
R1024x1024
1024x1024 resolution (DALL-E2, DALL-E3, GPT Image)
Declaration
public const string R1024x1024 = "1024x1024"
Field Value
| Type | Description |
|---|---|
| string |
R1024x1536
1024x1536 portrait resolution (GPT Image)
Declaration
public const string R1024x1536 = "1024x1536"
Field Value
| Type | Description |
|---|---|
| string |
R1024x1792
1024x1792 portrait resolution (DALL-E3)
Declaration
public const string R1024x1792 = "1024x1792"
Field Value
| Type | Description |
|---|---|
| string |
R1080x1080
1080x1080 resolution - Instagram/Facebook profile optimal
Declaration
public const string R1080x1080 = "1080x1080"
Field Value
| Type | Description |
|---|---|
| string |
R1080x1350
1080x1350 resolution - Instagram feed optimal
Declaration
public const string R1080x1350 = "1080x1350"
Field Value
| Type | Description |
|---|---|
| string |
R1080x1920
1080x1920 resolution - Full HD vertical (recommended for social media)
Declaration
public const string R1080x1920 = "1080x1920"
Field Value
| Type | Description |
|---|---|
| string |
R1280x720
1280x720 resolution - HD landscape
Declaration
public const string R1280x720 = "1280x720"
Field Value
| Type | Description |
|---|---|
| string |
R128x128
128x128 resolution (PixelLab)
Declaration
public const string R128x128 = "128x128"
Field Value
| Type | Description |
|---|---|
| string |
R1440x2560
1440x2560 resolution - QHD vertical
Declaration
public const string R1440x2560 = "1440x2560"
Field Value
| Type | Description |
|---|---|
| string |
R1536x1024
1536x1024 landscape resolution (GPT Image)
Declaration
public const string R1536x1024 = "1536x1024"
Field Value
| Type | Description |
|---|---|
| string |
R16x16
16x16 resolution (PixelLab)
Declaration
public const string R16x16 = "16x16"
Field Value
| Type | Description |
|---|---|
| string |
R1792x1024
1792x1024 landscape resolution (DALL-E3)
Declaration
public const string R1792x1024 = "1792x1024"
Field Value
| Type | Description |
|---|---|
| string |
R1920x1080
1920x1080 resolution - Full HD landscape (recommended for YouTube)
Declaration
public const string R1920x1080 = "1920x1080"
Field Value
| Type | Description |
|---|---|
| string |
R2048x2048
2048x2048 resolution - High resolution square
Declaration
public const string R2048x2048 = "2048x2048"
Field Value
| Type | Description |
|---|---|
| string |
R2160x3840
2160x3840 resolution - 4K vertical
Declaration
public const string R2160x3840 = "2160x3840"
Field Value
| Type | Description |
|---|---|
| string |
R2560x1440
2560x1440 resolution - QHD landscape
Declaration
public const string R2560x1440 = "2560x1440"
Field Value
| Type | Description |
|---|---|
| string |
R256x256
256x256 resolution (PixelLab, DALL-E2)
Declaration
public const string R256x256 = "256x256"
Field Value
| Type | Description |
|---|---|
| string |
R32x32
32x32 resolution (PixelLab)
Declaration
public const string R32x32 = "32x32"
Field Value
| Type | Description |
|---|---|
| string |
R3840x2160
3840x2160 resolution - 4K landscape
Declaration
public const string R3840x2160 = "3840x2160"
Field Value
| Type | Description |
|---|---|
| string |
R512x512
512x512 resolution (PixelLab, DALL-E2)
Declaration
public const string R512x512 = "512x512"
Field Value
| Type | Description |
|---|---|
| string |
R64x64
64x64 resolution (PixelLab)
Declaration
public const string R64x64 = "64x64"
Field Value
| Type | Description |
|---|---|
| string |
R720x1280
720x1280 resolution - Sora-2 default vertical video
Declaration
public const string R720x1280 = "720x1280"
Field Value
| Type | Description |
|---|---|
| string |
Properties
| Edit this page View SourceIsLandscape
Returns true if the media size has greater width than height
Declaration
public bool IsLandscape { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsPortrait
Returns true if the media size has greater height than width
Declaration
public bool IsPortrait { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsSquare
Returns true if the media size has equal width and height
Declaration
public bool IsSquare { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Value
Gets the size value, defaults to Auto if not set
Declaration
public string Value { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceEquals(MediaSize)
Checks if two MediaSize instances are equal
Declaration
public bool Equals(MediaSize other)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaSize | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Checks if this MediaSize equals another object
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceGetDisplayedValues(string)
Gets display-friendly names for supported image sizes of a specific model
Declaration
public static Dictionary<string, string> GetDisplayedValues(string modelId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | modelId | The model identifier |
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | Dictionary mapping size values to display names |
GetHashCode()
Gets the hash code for this MediaSize
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceGetSoraDisplayedValues(MediaAspect)
Gets display-friendly names for Sora video sizes based on aspect ratio
Declaration
public static Dictionary<string, string> GetSoraDisplayedValues(OpenAITypes.MediaAspect aspect)
Parameters
| Type | Name | Description |
|---|---|---|
| OpenAITypes.MediaAspect | aspect | The media aspect ratio |
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | Dictionary mapping size values to display names |
GetSoraSupportedSizes(MediaAspect)
Gets the supported video sizes for Sora based on aspect ratio
Declaration
public static string[] GetSoraSupportedSizes(OpenAITypes.MediaAspect aspect)
Parameters
| Type | Name | Description |
|---|---|---|
| OpenAITypes.MediaAspect | aspect | The media aspect ratio |
Returns
| Type | Description |
|---|---|
| string[] | Array of supported size strings |
GetSupportedImageSizes(string)
Gets the supported image sizes for a specific AI model
Declaration
public static string[] GetSupportedImageSizes(string modelId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | modelId | The model identifier (e.g., "dall-e-2", "dall-e-3") |
Returns
| Type | Description |
|---|---|
| string[] | Array of supported size strings |
ToString()
Returns the string representation of the media size
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceTryAdjustValue(string, string, out string)
Attempts to adjust a selected value to match the supported sizes of a model
Declaration
public static bool TryAdjustValue(string modelId, string selectedValue, out string adjustedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | modelId | The model identifier |
| string | selectedValue | The currently selected size value |
| string | adjustedValue | The adjusted value if adjustment was needed |
Returns
| Type | Description |
|---|---|
| bool | True if the value was already supported, false if it was adjusted |
TryGetWidthHeight(MediaSize, out int, out int)
Attempts to parse width and height from a MediaSize
Declaration
public static bool TryGetWidthHeight(MediaSize size, out int w, out int h)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaSize | size | MediaSize to parse |
| int | w | Parsed width |
| int | h | Parsed height |
Returns
| Type | Description |
|---|---|
| bool | True if parsing succeeded |
TryGetWidthHeight(out int, out int)
Attempts to parse width and height from this MediaSize instance
Declaration
public bool TryGetWidthHeight(out int w, out int h)
Parameters
| Type | Name | Description |
|---|---|---|
| int | w | |
| int | h |
Returns
| Type | Description |
|---|---|
| bool |
TryGetWidthHeight(string, out int, out int)
Attempts to parse width and height from a size string
Declaration
public static bool TryGetWidthHeight(string value, out int w, out int h)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | Size string (e.g., "1024x768") |
| int | w | Parsed width |
| int | h | Parsed height |
Returns
| Type | Description |
|---|---|
| bool | True if parsing succeeded |
TryParse(string, out MediaSize)
Attempts to parse a string into a MediaSize
Declaration
public static bool TryParse(string s, out MediaSize size)
Parameters
| Type | Name | Description |
|---|---|---|
| string | s | String to parse |
| MediaSize | size | Resulting MediaSize |
Returns
| Type | Description |
|---|---|
| bool | True if parsing succeeded |
Operators
| Edit this page View Sourceimplicit operator string(MediaSize)
Converts MediaSize to string
Declaration
public static implicit operator string(MediaSize size)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaSize | size |
Returns
| Type | Description |
|---|---|
| string |
implicit operator MediaSize(string)
Converts string to MediaSize
Declaration
public static implicit operator MediaSize(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value |
Returns
| Type | Description |
|---|---|
| MediaSize |