Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Width and Height Parameters to ASCII Stream Output #1119

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

skrashevich
Copy link
Contributor

This pull request introduces significant enhancements to the internal mjpeg package, particularly the ASCII stream functionality:

  1. New Width and Height Parameters:

    • Added width and height parameters to the NewWriter function, allowing users to specify the dimensions of the ASCII output.
    • Updated the README.md to include documentation for width and height parameters, along with examples.
  2. Function Modifications:

    • Modified the outputMjpeg function to extract width and height from the HTTP request and pass them to NewWriter.
    • Enhanced the NewWriter function to handle the new parameters and resize the image according to specified dimensions before processing.
  3. Image Resizing:

    • Introduced a utility function resizeImage which resizes the input image based on the provided width and height, maintaining the aspect ratio if only one dimension is provided.
  4. Additional Minor Refactoring:

    • Consolidated constant definitions for color codes for better readability.
    • Refactored sections of the code for improved clarity and maintainability.

By adding these parameters, users now have better control over the ASCII output size, allowing more flexibility for different display requirements.

Examples:

# Example with width and height
curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&width=100&height=40"

# Example with color, width, and height
curl "http://192.168.1.123:1984/api/stream.ascii?src=gamazda&color=256&width=80&height=20"

@AlexxIT AlexxIT self-assigned this May 18, 2024
Enhance resizeImage function for better aspect ratio handling and add comprehensive unit tests for xterm256color and resizeImage functions.
@skrashevich skrashevich force-pushed the feat-ascii-size branch 3 times, most recently from c469b17 to c36f6db Compare June 4, 2024 09:47
…rmatting

Added a new endpoint `/api/stream.ascii` for streaming video as ASCII art with configurable parameters. Corrected the indentation of default responses across multiple endpoints for consistency.
@skrashevich
Copy link
Contributor Author

Up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants