mczachurski / wallpapper

:computer: Console application for creating dynamic wallpapers for macOS Mojave and newer
MIT License
3.32k stars 137 forks source link

Allow the same file to appear multiple times #57

Closed iiKurt closed 2 years ago

iiKurt commented 2 years ago

When the same file is specified multiple times in the JSON file, only the first file is considered when generating the output HEIC. This commit allows the same file to be duplicated in the output HEIC.

This is useful if we want to have the same file appear multiple times, but with a different times/sun positions.

mczachurski commented 2 years ago

I'm not sure that this change is needed to support same files to appear multiple times. It's possible right now. HEIC file looks like that:

IMG_0057

Thus we have list with image files and metadata. In metadata we can point to the same file multiple times. And because we are storing the physical image only once the HEIC file is smaller.

You can try this with json like that:

[
  {
    "fileName": "1.jpeg",
    "isPrimary": true,
    "isForLight": true,
    "altitude": 0.0,
    "azimuth": 270
  },
  {
    "fileName": "2.jpeg",
    "isForDark": true,
    "altitude": -25,
    "azimuth": 70
  },
  {
    "fileName": "2.jpeg",
    "altitude": -9,
    "azimuth": 80
  },
  {
    "fileName": "3.jpeg",
    "altitude": 0.0,
    "azimuth": 90
  }
]

So we have four nodes but two of them points to the same file 2.jpeg.

iiKurt commented 2 years ago

Thanks for the quick and detailed response!

Ah, I had wondered if HEIC files could point two different nodes to the same image data. As when I initially tried it out, Preview didn't pick up the multiple copies. However, when I extracted the metadata from the image using ./wallpapper it only showed 5 entries, when I supplied 7 entries in the input JSON. Perhaps a bug? I'll have another go at getting two nodes to point to the same image. I suppose we don't this change then.

Good to know that the HEIC format supports this though! My files are about to get a whole lot smaller :^)