Search Results for

    Show / Hide Table of Contents

    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.

    Implements
    IStringWrapper
    IEquatable<MediaSize>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Glitch9.AIDevKit
    Assembly: Glitch9.AIDevKit.dll
    Syntax
    [Serializable]
    public readonly struct MediaSize : IStringWrapper, IEquatable<MediaSize>

    Constructors

    | Edit this page View Source

    MediaSize(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

    | Edit this page View Source

    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 Source

    Auto

    Automatic size selection by the AI model

    Declaration
    public const string Auto = "auto"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1024x1024

    1024x1024 resolution (DALL-E2, DALL-E3, GPT Image)

    Declaration
    public const string R1024x1024 = "1024x1024"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1024x1536

    1024x1536 portrait resolution (GPT Image)

    Declaration
    public const string R1024x1536 = "1024x1536"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1024x1792

    1024x1792 portrait resolution (DALL-E3)

    Declaration
    public const string R1024x1792 = "1024x1792"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1080x1080

    1080x1080 resolution - Instagram/Facebook profile optimal

    Declaration
    public const string R1080x1080 = "1080x1080"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1080x1350

    1080x1350 resolution - Instagram feed optimal

    Declaration
    public const string R1080x1350 = "1080x1350"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1080x1920

    1080x1920 resolution - Full HD vertical (recommended for social media)

    Declaration
    public const string R1080x1920 = "1080x1920"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1280x720

    1280x720 resolution - HD landscape

    Declaration
    public const string R1280x720 = "1280x720"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R128x128

    128x128 resolution (PixelLab)

    Declaration
    public const string R128x128 = "128x128"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1440x2560

    1440x2560 resolution - QHD vertical

    Declaration
    public const string R1440x2560 = "1440x2560"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1536x1024

    1536x1024 landscape resolution (GPT Image)

    Declaration
    public const string R1536x1024 = "1536x1024"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R16x16

    16x16 resolution (PixelLab)

    Declaration
    public const string R16x16 = "16x16"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1792x1024

    1792x1024 landscape resolution (DALL-E3)

    Declaration
    public const string R1792x1024 = "1792x1024"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R1920x1080

    1920x1080 resolution - Full HD landscape (recommended for YouTube)

    Declaration
    public const string R1920x1080 = "1920x1080"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R2048x2048

    2048x2048 resolution - High resolution square

    Declaration
    public const string R2048x2048 = "2048x2048"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R2160x3840

    2160x3840 resolution - 4K vertical

    Declaration
    public const string R2160x3840 = "2160x3840"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R2560x1440

    2560x1440 resolution - QHD landscape

    Declaration
    public const string R2560x1440 = "2560x1440"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R256x256

    256x256 resolution (PixelLab, DALL-E2)

    Declaration
    public const string R256x256 = "256x256"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R32x32

    32x32 resolution (PixelLab)

    Declaration
    public const string R32x32 = "32x32"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R3840x2160

    3840x2160 resolution - 4K landscape

    Declaration
    public const string R3840x2160 = "3840x2160"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R512x512

    512x512 resolution (PixelLab, DALL-E2)

    Declaration
    public const string R512x512 = "512x512"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R64x64

    64x64 resolution (PixelLab)

    Declaration
    public const string R64x64 = "64x64"
    Field Value
    Type Description
    string
    | Edit this page View Source

    R720x1280

    720x1280 resolution - Sora-2 default vertical video

    Declaration
    public const string R720x1280 = "720x1280"
    Field Value
    Type Description
    string

    Properties

    | Edit this page View Source

    IsLandscape

    Returns true if the media size has greater width than height

    Declaration
    public bool IsLandscape { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsPortrait

    Returns true if the media size has greater height than width

    Declaration
    public bool IsPortrait { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsSquare

    Returns true if the media size has equal width and height

    Declaration
    public bool IsSquare { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    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 Source

    Equals(MediaSize)

    Checks if two MediaSize instances are equal

    Declaration
    public bool Equals(MediaSize other)
    Parameters
    Type Name Description
    MediaSize other
    Returns
    Type Description
    bool
    | Edit this page View Source

    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
    ValueType.Equals(object)
    | Edit this page View Source

    GetDisplayedValues(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

    | Edit this page View Source

    GetHashCode()

    Gets the hash code for this MediaSize

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()
    | Edit this page View Source

    GetSoraDisplayedValues(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

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    ToString()

    Returns the string representation of the media size

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()
    | Edit this page View Source

    TryAdjustValue(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

    | Edit this page View Source

    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

    | Edit this page View Source

    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
    | Edit this page View Source

    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

    | Edit this page View Source

    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 Source

    implicit 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
    | Edit this page View Source

    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

    Implements

    IStringWrapper
    IEquatable<T>

    Extension Methods

    EventExtensions.ToDelta<T>(T, string, int, string, bool)
    EventExtensions.ToDone<T>(T, string, int, string)
    EventExtensions.ToEvent<T>(T)
    EventExtensions.UpcastDelta<T1, T2>(T1, string, int, string, bool)
    FallbackExtensions.IsOr<TParent, TChild>(TParent, TChild)
    ResponseCastingExtensions.GetResult<T>(T)
    SystemExtensions.GetHashCodeOrDefault<T>(T)
    SystemExtensions.GetName(object)
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation