How to convert a HEIF/HEIC image files to JPEG/PNG for Plex Media Server?

How to convert a HEIF/HEIC image files to JPEG/PNG for Plex Media Server?
Converting Images from iPhone/iPad for Plex Media Server

Are you looking to convert your HEIC images to PNG format? sips (Scriptable Image Processing System) is a command-line tool that is built into macOS and can help you easily convert your images from one format to another. Here's how you can use sips to convert HEIC images to PNG:

  1. Open Terminal on your Mac.
  2. Type the following command to navigate to the directory where your HEIC images are located: cd /path/to/directory
  3. To convert a single HEIC image to PNG, type the following command: sips -s format png image.HEIC --out image.png
  4. To convert multiple HEIC images to PNG, you can use the following command: for file in *.heic; do sips -s format png "$file" --out "${file%.*}.png"; done
  5. The converted images will be saved in the same directory as the original images.

However, I created a Bash script that also retains the metadata of the files:

Make sure you create a folder called converted_images in the same directory where your HEIC files are located:

for imgFile in *.HEIC; do
  echo "Reading Image File = "$imgFile""
  echo "Converting "$imgFile" to "$imgFile.png""
  sips -s format png "$imgFile" --out "converted_images/$imgFile.png"
  echo "Conversion completed for "$imgFile" as "$imgFile.png""
  echo "Reading original creation date"
  date=$(stat -f "%SB" -t "%m/%d/%y %H:%M:%S" "$imgFile")
  echo "setting the date to be "$date""
  echo "writing original creation date as modification and creation date"
  SetFile -md "$date" converted_images/${imgFile}.png
  echo "Completed Processing for $imgFile"
  echo "--------------------------------"
done

Make the script executable before you can run it!

That's it! With just a few simple commands, you can easily convert your HEIC images to PNG while preserving their metadata using sips. The tool is scriptable and allows you to easily batch convert multiple images at once, saving you time and effort. Give it a try and see how it can help you easily convert your images while preserving their metadata.

Note: Both PNG and JPG are common image formats that are widely used for storing and sharing digital images. However, there are some differences between the two formats that you should consider when deciding which one to use.

PNG (Portable Network Graphics) is a lossless image format that is best suited for images with large areas of solid color, such as logos or icons. PNG images retain their original quality when they are saved and do not lose any detail or sharpness. They also support transparent backgrounds, which is useful if you want to overlay the image on top of another image or design.

On the other hand, JPG (Joint Photographic Experts Group) is a lossy image format that is best suited for photographs and images with lots of details and gradients. JPG images are smaller in size compared to PNG images, making them easier to share and upload online. However, they do lose some quality when they are saved, especially if they are saved at a low quality setting.

In general, if you want to retain the original quality of the image and do not need to worry about file size, you should consider converting the HEIC file to PNG. If file size is a concern and the image does not have a transparent background, you can consider converting the HEIC file to JPG.

You can also use libheif and ImageMagick tools to convert your image files!