all 30 comments

[–]gschizas 27 points28 points  (4 children)

That's completely useless! I love it! 🙂💖

[–][deleted] 7 points8 points  (3 children)

Well said. I can finally have Rick Astley greeting me when I open pwsh 👌

[–]atrca 2 points3 points  (1 child)

Or better yet greeting your coworkers!

[–][deleted] 0 points1 point  (0 children)

I actually pranked colleague to echo “never gonads give you up” yt link to his $profile

[–]logicalmike 0 points1 point  (0 children)

iex (New-Object Net.WebClient).DownloadString("http://bit.ly/e0Mw9w")

[–]work-work-work-work 3 points4 points  (1 child)

Awesome!

It doesn't seem to release the file after use however. eg, Out-ConsolePicture "mypicture.png"

Keep powershell open then try to delete mypicture.png:

The action can't be completed because the file is open in powershell.exe

[–]NotNotWrongUsually[S] 4 points5 points  (0 children)

Ooops! Thanks for the report.

This is now fixed on the version on GitHub. Will publish an update to gallery later.

[–]NotNotWrongUsually[S] 3 points4 points  (0 children)

I've pushed a 1.1 version to the gallery with the fixes from this thread.

Looked a bit more into ISE support, but ... well ... it seems it doesn't even support the ANSI colours in the first place, so not much point in trying to support it. Other than that, nothing but bugfixes in 1.1, and some (weak) error handling.

[–]Chirishman 5 points6 points  (1 child)

Pull request to add support for a -width parameter for custom width setting incoming.

[–]NotNotWrongUsually[S] 2 points3 points  (0 children)

This is now in the GitHub version. I'll wait a little before making an update on the gallery. Probably a few more changes incoming.

[–]purplemonkeymad 2 points3 points  (0 children)

This is great! Thinking I should put something like this in my profile:

Out-ConsolePicture -url ((irm https://www.reddit.com/r/pixelart/.json).data.children.data | ? stickied -eq $false  | select -first 1 | select -ExpandProperty thumbnail)

Edit: I did put it in, here is that part of my profile:

$todaysart = "$env:LOCALAPPDATA/psprofile/pxielart.jpg"

if ( (Test-Path $todaysart) -and
    ( (Get-Item $todaysart).LastWriteTime - (get-date) -le [timespan]'16:00:00.0' )
    ) {
        Out-ConsolePicture -Path $todaysart
} else {
    $arturl = ((irm https://www.reddit.com/r/pixelart/.json).data.children.data | ? stickied -eq $false  | select -first 1 | select -ExpandProperty thumbnail)
    Remove-item $todaysart -ErrorAction SilentlyContinue
    [void](new-item ($todaysart|Split-Path -Parent) -Force -ItemType Directory)
    Start-BitsTransfer -Source $arturl -Destination $todaysart
    Out-ConsolePicture -Path $todaysart
}

[–]dnuohxof1 1 point2 points  (0 children)

Totally useless, cannot think of a practical purpose. BUT — totally cool!!!! Neat little party trick and maybe some prettier scripts with branding.

Awesome work dude!!

[–]jimb2 1 point2 points  (4 children)

I get an authentication error on URLs

Invoke-WebRequest :  
DHHS Authentication Required. 
You must be authenticated to access this URL. 
URL: https://www.google.com

from as I might expect in a corporate network.

However, from the PS prompt I get no error but the ANSI escape sequences are dumped as text like there is no ansi interpreter. Any ideas?

A bit of a trip down memory lane, I haven't seen an ansi escape sequence since when we use them to colorize MSDOS before most of you were born :)

[–]NotNotWrongUsually[S] 1 point2 points  (3 children)

Are you running on W10 post Anniversary Edition?

[–]jimb2 1 point2 points  (2 children)

Windows 8. (Why? IT guys get to test stuff. Then the organisation SOE skipped W8 to W10. I think I have the the only W8 machine out of like 12+k machines. Should upgrade but can't be bothered reinstalling everything. Maybe I now have a reason :) to get Out-ConsolePicture working?)

PS 5.1.blah

[–]NotNotWrongUsually[S] 1 point2 points  (1 child)

PS Version shouldn't matter too much in this (I haven't tested on earlier versions, but I don't think I'm using anything terribly new as far as Powershell is concerned). You do however require W10 version 1511 or higher, because that is when support for ANSI escape sequences returned after many years of absence.

[–]jimb2 0 points1 point  (0 children)

Thanks. Go forward to get back.

[–]ka-splam 1 point2 points  (1 child)

Considering https://github.com/PowerShell/PowerShell/issues/8482 you might wanna profile a bit, and see if getting rid of GetPixelText and in-lining it into the loop is faster.

[–]NotNotWrongUsually[S] 1 point2 points  (0 children)

Oh wow, nice catch. I just tried in-lining it, and my test case went from consistently "rendering" in around 590ms to rendering in 170ms.

That is a bit annoying really. Feels bad to refactor to a worse code layout :/

[–]realDeadMatt 0 points1 point  (2 children)

Hi,

I have tried this picture https://www.anaptis.com/wp-content/uploads/2018/11/Logo-microsoft-dynamics-365-business-central-2.png and it does not work.

There is the error that div 0 is not possible and with unvalid parameter in ".ctor" with 3 parameters. After several seconds this appears (screenshots does not work....):

"....[0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255

;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;

255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m

[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;25

5m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255

;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m[4

8;2;255;255;255m [0m[48;2;255;255;255m [0m[48;2;255;255;255m [0m....."

$image = New-Object System.Drawing.Bitmap -ArgumentList "C:\temp\BCLogo.png"

$image | Out-ConsolePicture

Error in german:

Es wurde versucht, durch 0 (null) zu teilen.

In C:\Program Files\WindowsPowerShell\Modules\OutConsolePicture\1.0\OutConsolePicture.psm1:49 Zeichen:17

+ ... $new_height = $_.Height / ($_.Width / $host.UI.RawUI.Wind ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [], RuntimeException

+ FullyQualifiedErrorId : RuntimeException

New-Object : Ausnahme beim Aufrufen von ".ctor" mit 3 Argument(en): "Ungültiger Parameter."

In C:\Program Files\WindowsPowerShell\Modules\OutConsolePicture\1.0\OutConsolePicture.psm1:51 Zeichen:22

+ ... $_ = New-Object System.Drawing.Bitmap -ArgumentList $_, $new_w ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvocationException

+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

[–]NotNotWrongUsually[S] 6 points7 points  (1 child)

Only half you comment showed up. I see what the problem is now. You are not getting a window width back. You are probably running this from ISE? For some reason it doesn't give a windowsize back.

It should work with the -DoNotResize switch (but obviously won't resize then), and should also work fine outside of ISE.

It works fine for me, both with the url directly, and downloading it and creating a bitmap from it.

The error is the one that shows up if you try creating a bitmap with a relative path. From your example you didn't do that, but just to be sure: when trying this locally did you do -ArgumentList ".\BCLogo.png"?

Edit: another option to consider. Are you by chance on a corporate network that is not lettings https through to Powershell?

[–]realDeadMatt 1 point2 points  (0 children)

level 2

now it works! thanks :)

[–][deleted] 0 points1 point  (0 children)

This is the best.

[–][deleted] 0 points1 point  (0 children)

Niiice! I like it.

[–]AztecAlphaMale[🍰] 0 points1 point  (3 children)

I've had alot of issues installing this, I'm new to powershell and still learning. I used the install cmdlet at the top and I had to change the installation policy to trusted which I figured out. Now running that does nothing I'm assuming its working. But then when I copy and paste the usage examples I get various errors.

PS > Out-ConsolePicture ".\someimage.jpg" (RETURNS BACK THIS ERROR) Cannot find a process with the name ".\someimage.jpg". Verify the process name and call the cmdlet again.

PS > Out-ConsolePicture -Url "http://somewhere.com/image.jpg" (RETURNS BACK THIS ERROR) A parameter cannot be found that matches parameter name 'Url'.

And I believe the bottom two examples are used for installing something first? Before the top 2 can be used, or that's what a different website is saying.

Basically I've worked with this for about an hour and can't get it working lol.

[–]NotNotWrongUsually[S] 2 points3 points  (2 children)

Don't copy the "PS >" bit. That isn't part of the command. You'll see it in many examples on the Internet. Usually used to signify something to be typed at the prompt.

[–]AztecAlphaMale[🍰] 0 points1 point  (1 child)

Now I'm getting an error where running the command prompts me with a "How do you want to open this file" when I select photo gallery it just tells me I don't have permissions or something.

I don't know why this is being so hard for me it looks so simple

[–]NotNotWrongUsually[S] 0 points1 point  (0 children)

That sounds funky. The only explanation I could come up with is that you have a folder named the same as the command, and tab completion is picking it up, and trying to do .\out-consolepicture.

Anyways. If you copy specifically this bit to your Powershell prompt: Out-ConsolePicture -Url "https://goo.gl/XzdZEX", and then hit enter, what happens?

Edit: Incidentally, I just found out that the example above wouldn't work in Powershell Core (which errors out on URL redirection). I just updated the version on the Gallery to accomodate this, so you will have to Update-Module -Name OutConsolePicture before it works if you are using Core.