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

[BUG]: $image variable not working correctly. #210

Open
jjfantini opened this issue Feb 6, 2024 · 3 comments
Open

[BUG]: $image variable not working correctly. #210

jjfantini opened this issue Feb 6, 2024 · 3 comments

Comments

@jjfantini
Copy link

I am using winfetch@latest Powershell Script. I am trying to use a .png image or ASCII art as the image to the left of the details display.

However, when using this image, I encounter an error:

Invoke-WebRequest: C:\Users\jjfan\Documents\PowerShell\Scripts\winfetch.ps1:374
Line |
 374 |  … itmap]::FromStream((Invoke-WebRequest $image -UseBasicParsing).RawCon …
     |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | No such host is known.
RuntimeException: C:\Users\jjfan\Documents\PowerShell\Scripts\winfetch.ps1:378
Line |
 378 |          [int]$ROWS = $OldImage.Height / $OldImage.Width * $COLUMNS /  …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Attempted to divide by zero.
InvalidArgument: C:\Users\jjfan\Documents\PowerShell\Scripts\winfetch.ps1:379
Line |
 379 |          $Bitmap = New-Object System.Drawing.Bitmap @($OldImage, [Draw …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot convert value "35," to type "System.Drawing.Size". Error: " is not a valid value for Int32. (Parameter
     | 'value')"
InvalidOperation: C:\Users\jjfan\Documents\PowerShell\Scripts\winfetch.ps1:426
Line |
 426 |          $Bitmap.Dispose()
     |          ~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.
InvalidOperation: C:\Users\jjfan\Documents\PowerShell\Scripts\winfetch.ps1:427
Line |
 427 |          $OldImage.Dispose()
     |          ~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.

Here is my config file:

# ===== WINFETCH CONFIGURATION =====

$image = "C:\Users\jjfan\Documents\Powershell\humblDeveloper_winfetch.png"
# $noimage = $true

# Display image using ASCII characters
$ascii = $true

# Set the version of Windows to derive the logo from.
# $logo = "Windows 11"

# Specify width for image/logo
# $imgwidth = 40

# Specify minimum alpha value for image pixels to be visible
# $alphathreshold = 50

# Custom ASCII Art
# This should be an array of strings, with positive
# height and width equal to $imgwidth defined above.
 $CustomAscii = @(
     "⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣾⣿⣦⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣶⣶⣾⣷⣶⣆⠸⣿⣿⡟⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣷⡈⠻⠿⠟⠻⠿⢿⣷⣤⣤⣄⠀⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⣴⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣦⠀ ⠀"
     "⠀⠀⠀⢀⣤⣤⡘⢿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⡇ ⠀"
     "⠀⠀⠀⣿⣿⣿⡇⢸⣿⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢈⣉⣉⡁ ⠀"
     "⠀⠀⠀⠈⠛⠛⢡⣾⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⡇ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⠟⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⡿⢁⣴⣶⣦⣴⣶⣾⡿⠛⠛⠋⠀⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠿⠿⢿⡿⠿⠏⢰⣿⣿⣧⠀⠀ ⠀"
     "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⠟⠀⠀ ⠀"
 )

# Make the logo blink
# $blink = $true

# Display all built-in info segments.
# $all = $true

# Add a custom info line
# function info_custom_time {
#     return @{
#         title = "Time"
#         content = (Get-Date)
#     }
# }

# Configure which disks are shown
# $ShowDisks = @("C:", "D:")
# Show all available disks
$ShowDisks = @("*")

# Configure which package managers are shown
# disabling unused ones will improve speed
# $ShowPkgs = @("winget", "scoop", "choco")

# Use the following option to specify custom package managers.
# Create a function with that name as suffix, and which returns
# the number of packages. Two examples are shown here:
# $CustomPkgs = @("cargo", "just-install")
# function info_pkg_cargo {
#     return (cargo install --list | Where-Object {$_ -like "*:" }).Length
# }
# function info_pkg_just-install {
#     return (just-install list).Length
# }

# Configure how to show info for levels
# Default is for text only.
# 'bar' is for bar only.
# 'textbar' is for text + bar.
# 'bartext' is for bar + text.
$cpustyle = 'bartext'
$memorystyle = 'bartext'
$diskstyle = 'bartext'
$batterystyle = 'bartext'


# Remove the '#' from any of the lines in
# the following to **enable** their output.

@(
    "title"
    "dashes"
    "os"
    "computer"
    # "kernel"
    # "motherboard"
    # "custom_time"  # use custom info line
    "uptime"
    # "ps_pkgs"  # takes some time
    # "pkgs"
    # "pwsh"
    # "resolution"
    # "terminal"
    # "theme"
    "cpu"
    "gpu"
    # "cpu_usage"  # takes some time
    "memory"
    "disk"
    # "battery"
    # "locale"
    # "weather"
    # "local_ip"
    # "public_ip"
    "blank"
    "colorbar"
)

I am not sure why -BasicParsing is trying to connect to a host to load my image from a filepath. I am not very experienced at PS, so not the best eyes to look over the script, and it needs more than ChatGPT can do...

@rashil2000
Copy link
Member

Can you share the image file also?

@jjfantini
Copy link
Author

humblDeveloper_winfetch

I had this image as an image before, so it shouldn't be a problem.

@rashil2000
Copy link
Member

I'm unable to repro this:
image

Could you try debugging the script? Try to put Write-Host $image somewhere inside the script to see whether it contains the correct value.

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

No branches or pull requests

2 participants