Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
adee pe Simpatie.ro
Femeie
24 ani
Mures
cauta Barbat
24 - 59 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [WINDOWS] Convert Image to Icon File and Display as Folder Icon Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2228
I need to set some representative images as the icons of folders, instead of using the thumbnail view which, even if it shows an image as preview and this can be set easily, it will only show part of the image obscured by the folder lid... thing. Anyway, I wanna disable thumbnails and use icons on folders instead. Plus, you cannot use thumbnail preview in List or Details view mode, and they will not show in the taskbar either. Also, other files might obscure a thumbnail image, for example if you also have a .url internet shortcut inside the folder, the thumbnail of the image will be shown either above or under the icon of your browser, and if you have multiple .url files the desired thumbnail might not even be shown at all.

Regardless of folder contents, the icon will be seen in all Views, whether it's Extra large icons or Details, and it will also be seen on the Taskbar.

1. Prerequisites - these are a MUST:
- ImageMagick Windows Binary Release:
- The possibility to run PowerShell as an Administrator

2. Install ImageMagick binaries and make sure at the screen with options you select "Install command line tools" or "Install legacy utilities".

3. Pick your desired image file and put it into a desired folder, for the sake of this tutorial let's name the image "image.jpg" and put it in "D:\Image Conversion" folder.

4. I've learned that it's best to crop it square-size for better conversion, as in make an image that has the same width and height, so do this. It will be downsized to a 256 x 256 ico file, but that's the PowerShell script's job.

5. Copy the following code and paste it into notepad, then save the file as a .ps1 file named ConvertJpgToIco, or whatever name you want - you will use it later, so whatever name you pick you will have to replace it in the PowerShell command. I'm sticking with ConvertJpgToIco.ps1

I am also saving ConvertJpgToIco.ps1 into the same folder as the image file I put there in step 3. This is the same folder where I will save the icon the script will generate for me:  "D:\Image Conversion"

Without further ado, here's the ConvertJpgToIco.ps1 script provided by source:

param (
    [string]$inputImage,
    [string]$outputIcon
)

# Function to check if ImageMagick is installed
function Check-ImageMagick {
    $imageMagickPath = "magick"
    if (-not (Get-Command $imageMagickPath -ErrorAction SilentlyContinue)) {
        Write-Error "ImageMagick 'magick' command not found. Please ensure ImageMagick is installed and added to PATH."
        exit 1
    }
    return $imageMagickPath
}

# Main function to convert JPG to ICO
function Convert-Image {
    param (
        [string]$inputImage,
        [string]$outputIcon
    )
   
    $imageMagickPath = Check-ImageMagick

    # Convert JPG to ICO
    & $imageMagickPath $inputImage -resize 256x256 $outputIcon

    if ($?) {
        Write-Host "Conversion complete: $outputIcon"
    } else {
        Write-Error "Conversion failed. Please check the input image path and try again."
    }
}

# Validate input parameters
if (-not (Test-Path $inputImage)) {
    Write-Error "Input image file does not exist: $inputImage"
    exit 1
}

Convert-Image -inputImage $inputImage -outputIcon $outputIcon

6. Open Start Menu and type PowerShell, then Run as Administrator

Normally one cannot run PowerShell scripts on their PC as they can be very dangerous codes. So we will have to bypass the security policy for a little while to do that, then enable it back again to maintain security.
If you prefer to skip this tutorial and go and install some third party application to convert the image to icon, one that won't require you to bypass security policies, now it's the time to do it. If not, well, bear with me.

7. In PowerShell (PS), run the following command and when asked about Execution Policy Change type Y and press enter

Set-ExecutionPolicy RemoteSigned

8. In PS, change the directory path to the folder where ConvertJpgToIco.ps1 is located, in my case to D:\Image Conversion, like this:

cd "D:\Image Conversion"

9. Run the following line to convert the jpg image to ico, using the ps1 script:

.\ConvertJpgToIco.ps1 -inputImage "D:\Image Conversion\image.jpg" -outputIcon "D:\Image Conversion\image.ico"

10. You should receive a confirmation message similar to the one below. If no message is received, you must have not done one of the steps above.

Conversion complete: "D:\Image Conversion\image.ico"

11. Now it's time to prevent ps1 scripts from being run this way. Run the following command and when asked about Execution Policy Change type Y and press enter

Set-ExecutionPolicy Restricted

12. To set the ico file as a folder icon, simply put the ico file inside the desired folder, then right click inside the folder - Properties - Customize - Change icon... and pick the desired icon.

Now you can disable thumbnails by going to Explorer in Options (former Folder Options) - View - check Always show icons, never thumbnails
Or you can leave thumbnails enabled, and with the ico thing set in step 12 you will be able to see an icon for the folder even in the List or Details views, and also on the Taskbar.





Source for the ps1 file: ChatGPT


_______________________________________


pus acum 5 luni
   
Pagini: 1  

Mergi la