ConvertTo-Heic icon indicating copy to clipboard operation
ConvertTo-Heic copied to clipboard

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

Open Tom2112 opened this issue 5 years ago • 4 comments

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

Tom2112 avatar Nov 25 '20 15:11 Tom2112

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

DavidAnson avatar Nov 25 '20 17:11 DavidAnson

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.

Tom2112 avatar Nov 25 '20 19:11 Tom2112

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.

DavidAnson avatar Nov 25 '20 19:11 DavidAnson

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

CtheG avatar Dec 23 '21 21:12 CtheG