DavidAnson / ConvertTo-Heic

A PowerShell script that converts image files to the efficient HEIC format
MIT License
47 stars 7 forks source link

When piping directory to script, new HEIC filenames include previous file extension #4

Open Tom2112 opened 3 years ago

Tom2112 commented 3 years ago

I noticed that when piping the results of a directory command to your script, that the resulting new filenames include the old file extension, such as myfile.jpg.heic rather than myfile.heic.

This can be corrected by changing line 81 of your script from: $outputFileName = $inputFile.Name + ".heic"; to: $outputFileName = $inputFile.DisplayName + ".heic"; With the change it will always drop the old file extension from the new file's name.

Thanks, Tom

DavidAnson commented 3 years ago

This was deliberate - it makes it clear the HEIC file is not the original and indicates what the source file name was.

Tom2112 commented 3 years ago

Oh, OK. That's not how I'd think of it, but I get it. Thank you for writing this script, by the way!

One question: is there a way to control the amount of compression the conversion gives the image? I'm not noticing much difference in file size between the original jpg and the heic image.

DavidAnson commented 3 years ago

The JPEG encoder supports this, but I do not know if the HEIC one does. If so, it should be possible to pass that parameter in similarly. You can find examples doing this with JPEG on the web.

CtheG commented 2 years ago

FYI @Tom2112 The WIC-based ImageConverter from JohnnyWestlake does support the quality parameter for HEIC, copies metadata and offers a WRC as you probably wouldn't want to use the UWP-GUI.

You can now choose image quality whilst encoding to HEIC/HEIF! https://github.com/JohnnyWestlake/ImageConverter