Last active
May 22, 2017 10:21
-
-
Save altbdoor/c9c56680f7d7307d54779b18b039396a to your computer and use it in GitHub Desktop.
Converts PNG to JPG with png2jpeg.exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
#NoTrayIcon | |
#SingleInstance force | |
SetWorkingDir %A_ScriptDir% | |
FileInstall, png2jpeg.exe, %A_Temp%\png2jpeg.exe, 0 | |
; to compile this script, you will need to get png2jpeg.exe first | |
; https://sourceforge.net/projects/png2jpeg/ | |
; https://autohotkey.com/board/topic/63952-dragdrop-file-onto-ahk-script-pathname-of-file-into-var/?p=403191 | |
Loop %0% | |
{ | |
PngPath := "" | |
GivenPath := %A_Index% | |
Loop %GivenPath%, 1 | |
PngPath = %A_LoopFileLongPath% | |
; get the ext from path | |
PngPathExt = Substr(PngPath, -3) | |
StringLower, PngPathExt, PngPathExt | |
; simple check if its a png | |
If (PngPath != "" && PngPathExt == ".png") { | |
; prepare the jpg path | |
JpgPath := RegExReplace(PngPath, "i)\.png$", ".jpg") | |
; do your thang | |
RunWait, "%A_Temp%\png2jpeg.exe" -q 95 -o "%JpgPath%" "%PngPath%", , Hide | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment