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

✨ Enhancement: Add Parameter for Image Width Percentage in theBrain script #17

Open
chriskyfung opened this issue Mar 22, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@chriskyfung
Copy link
Owner

chriskyfung commented Mar 22, 2024

I am writing to make an enhancement to the Resize-TheBrainNotesYouTubeThumbnail.ps1 script located in the "theBrain" folder. This enhancement involves adding a new parameter to allow setting the percentage of the image width and adjusting the number with the string $width={$CurrentWidth}p when $ImageType is resized.

Here is the proposed change:

# Parameters
$ImageType = 'default'  # [ValidateSet('default', 'resized')]
$CurrentWidth = 30  # [ValidateRange(1,100)]
$NewWidth = 50  # [ValidateRange(1,100)]
if ($ImageType -eq 'default') {
  $MatchInfo = Get-ChildItem -Path $SubFolders -Filter $Filename -Recurse | Select-String '\/(hq|maxres)default.jpg\)' -List
} else {
  $MatchInfo = Get-ChildItem -Path $SubFolders -Filter $Filename -Recurse | Select-String ('\/(hq|maxres)default.jpg#\$width={0}p\$\)' -f $CurrentWidth) -List
}
if ($ImageType -eq 'default') {
$NewString = $Pattern.Replace(')', '#$width={0}p$)' -f $NewWidth)
} else {
  $NewString = $Pattern.Replace('#$width=30p$)', '#$width={0}p$)' -f $NewWidth)
}

This change will make the script more flexible by allowing users to specify the width of the image as a percentage. It also sets 'default' as the default value of the $ImageType parameter, which simplifies the usage of the script.

Please let me know if you have any questions or need further information.

@chriskyfung chriskyfung converted this from a draft issue Mar 22, 2024
@chriskyfung chriskyfung added the enhancement New feature or request label Mar 22, 2024
@chriskyfung chriskyfung self-assigned this Mar 22, 2024
chriskyfung added a commit that referenced this issue Mar 22, 2024
…nNotesYouTubeThumbnail.ps1

This commit introduces a new parameter to the `Resize-TheBrainNotesYouTubeThumbnail.ps1` script that allows users to set the width of the image as a percentage. This enhancement provides more flexibility to users by allowing them to specify the desired width of the image.

The changes include:
- Added a new parameter `$NewWidth` to set the width of the image as a percentage.
- Adjusted the string `$width={$CurrentWidth}p` to reflect the new width when `$ImageType` is resized.
- Set 'default' as the default value of the `$ImageType` parameter to simplify the usage of the script.

This change enhances the functionality of the script and makes it more user-friendly by providing more customization options.

Fixes #17
@chriskyfung chriskyfung moved this from 📋 Backlog to 👀 In review in PowerShell projects Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 👀 In review
Development

No branches or pull requests

1 participant