OSL ‐ URI Editing - Mistium/Origin-OS GitHub Wiki

URI Commands:

Open URI for Editing:

  • uri "start_editing" "uri"
    • Description: Opens a specific URI to be edited.
    • Example:
      uri "start_editing" "data: url"
      

Get Total Pixels:

  • uri "get_total_pixels"
    • Description: Retrieves the total number of pixels in the image.
    • Example:
      uri "get_total_pixels"
      log "console" data
      // logs the total pixels of the image to the browser console
      

Get Width and Height:

  • uri "get_width_height"
    • Description: Retrieves the width and height of the image and sets the data variable to an array of them.
    • Example:
      uri "get_width_height"
      log "console" data.[1]
      // outputs the width
      log "console" data.[2]
      // outputs the height
      

Upscale Image:

  • uri "upscale" 10
    • Description: Upscales the image by a specified percentage.
    • Example:
      uri "upscale" 10
      

Remove Colour:

  • uri "remove_colour" #hex_code 20
    • Description: Removes a specific color from the image.
    • Example:
      uri "remove_colour" #FF0000 20
      

Replace Colour:

  • uri "replace_colour" #hex_code #hex_code2 10
    • Description: Replaces one color with another in the image.
    • Example:
      uri "replace_colour" #FF0000 #00FF00 10
      

Add Hue:

  • uri "add_hue" #hue_colour
    • Description: Applies a hue to the image.
    • Example:
      uri "add_hue" #FFFF00
      

Remove Transparent Pixels:

  • uri "remove_transparent" "under/over/equal_to" 50
    • Description: Removes pixels under or over a specified transparency level.
    • Example:
      uri "remove_transparent" "over" 50
      

Get Pixel Colour:

  • uri "get_pixel" "index"
    • Description: Retrieves the color of the pixel at the specified index. (from top left, x is how many across, y is how many down)
    • Example:
      uri "get_pixel" 100 200
      log "console" data
      // logs the colour of the pixel to the console
      

Set Pixel Colour:

  • uri "set_pixel" "index" #hex_code
    • Description: Sets the color of the pixel at the specified index. (from top left, x is how many across, y is how many down)
    • Example:
      uri "set_pixel" 100 200 #FF0000
      

Set Pixels Colour:

  • uri "set_pixels" index1 index2 #hex_code
    • Description: Sets the color of all pixels between the specified indexes.
    • Example:
      uri "set_pixels" "100,200" "300,400" #00FF00
      

Stretch Image:

  • uri "stretch_uri" width height
    • Description: Stretches the image to the specified width and height.
    • Example:
      uri "stretch_uri" 800 600
      

Apply Effect:

  • uri "effect" "Saturation/Glitch/Chunk Glitch/Clip Glitch/Vignette/Ripple/Displacement/Posterize/Blur/Scanlines/Grain/Cubism" magnitude
    • Description: Applies an effect to the image with the specified magnitude.
    • Example:
      uri "effect" "Saturation" 50
      

Get Output URI:

  • uri "get_output"
    • Description: Retrieves the edited data URI.
    • Example:
      uri "get_output"
      image "load" data "test_image"
      // loads the uri into an image called "test_image"
      
      image "test_image"
      // renders the edited uri
      

These commands provide a range of functionalities for editing images in OSL, including manipulation of pixels, colors, transparency, and applying various effects.