Skip to content

Instantly share code, notes, and snippets.

View thomas694's full-sized avatar

Thomas thomas694

  • Somewhere
View GitHub Profile
@thomas694
thomas694 / Convert-PNG-files-in-folder-tree-to-JPEG-format.md
Created May 20, 2025 20:58
Convert PNG files in folder tree to JPEG format

Convert PNG files in folder tree to JPEG format

The script converts all PNG files in the specified folder tree to JPEG format running four workers in parallel

The attached powershell script searches all PNG files in the specified folder (including its subfolders) and converts them to JPEG, omitting PNG files with alpha channel used. If there is already a conversion from a previous run, the file is skipped. The filenames of the converted files get the extension for the target format appended.

For a conversion to JPEG format the following steps and their commands are used.

Determine if the PNG contains an alpha channel:

@thomas694
thomas694 / Convert-GIF-files-in-folder-tree-to-WebP-WebM-format.md
Created June 23, 2024 21:00
Convert GIF files in folder tree to WebP or WebM format

Convert GIF files in folder tree to WebP and WebM format

The script converts all GIF files in the specified folder tree to WebP and WebM format running four workers in parallel

The attached powershell script searches all GIF files in the specified folder (including its subfolders) and converts small files to WebP and the other files to WebM, using a treshold of 500KB. If there is already a conversion from a previous run, the file is skipped. The filenames of the converted files get the extension for the target format appended.

For a conversion to WebP format the following command is used:

$fn_webp = $item.FullName + ".webp"
C:\Tools\libwebp-1.2.2-windows-x64\bin\gif2webp -mt -mixed "$($item.FullName)" -o $fn_webp
@thomas694
thomas694 / list-all-48-or-64-bit-pngs-in-a-folder-tree.md
Created June 20, 2024 21:43
List all 48- or 64-bit PNGs in a folder tree

List all 48- or 64-bit PNGs in a folder tree

The script lists all 48-/64-bit PNGs in a folder tree, optionally as ready-made ImageMagick convert commands.

The attached powershell script searches all PNG files in the specified folder (including its subfolders) and outputs their filenames. Optionally with the 2nd parameter commands the filenames are embedded in command lines* for ImageMagick's Convert tool,
e.g.

C:\ImageMagick\convert.exe "D:\Folder\Image_64bit.png" -format png -depth 8 "D:\Folder\Image_64bit.png64.png"

*You have to adjust the path to your ImageMagick installation folder in the script once.

@thomas694
thomas694 / correct-gif-file-extensions-in-a-folder-tree.md
Created June 13, 2024 23:06
Correct GIF file extensions in a folder tree

Correct GIF file extensions in a folder tree

The script searches all files with extension .gif and appends the real extension, if necessary

The attached powershell script searches all files with extension .gif in the specified folder (including its subfolders), examines the file by checking the file header and appends the correct extension for the file content found.
The file formats JPG, PNG, WebM and WebP are recognized.

@thomas694
thomas694 / Convert-GIF-files-to-WebP-and-WebM-format-to-save-space-when-archiving.md
Created May 24, 2024 20:32
Convert GIF files to WebP and WebM format to save space when archiving

Convert GIF files to WebP and WebM format to save space when archiving

In the following post I want to share something for users who have tons of GIFs and want to store or archive the information in a more space-saving way.

Disclaimer: I do not take responsibility for any damages to or losses of your files.

Do you also have dozens of GIF files and ever wondered why a little bit blinking or a movement of few seconds needs several MB storage? If it is your own content, you need them in original state or anything similar, you can stop reading any further.

GIF files have been invented a very long time ago (you remember 1987?) and weren't meant to be used for displaying an anime or short movie clip and the like. Therefore the format and compression (is no longer) isn't efficient enough.

@thomas694
thomas694 / ShowUsedSpacePerFileTypeForFolders.ps1
Created April 18, 2023 21:45
Shows used space per file type of files in first-level subfolders of the specified path
<#
.SYNOPSIS
Shows used space per file type in all first-level subfolders.
.DESCRIPTION
Shows used space per file type of files in first-level subfolders of the specified path.
Example usages:
PS> sum_up_types_per_folder.ps1 C:\BasePath\
PS> sum_up_types_per_folder.ps1 C:\BasePath\ 1GB
@thomas694
thomas694 / Reddit_Scraper_Google_Sheets.gs
Last active April 22, 2023 19:01
Download subreddit info with Google Sheets and Apps Script via pushshift.io
/*
Reddit Scraper
--------------
download subreddit info with Google Sheets and Apps Script via pushshift.io
notes: https://www.labnol.org/internet/web-scraping-reddit/28369/
usage: Extensions > Apps Script, insert script and save, reopen doc
and use new menu
extensions: 2022 by thomas694 (@GH)