# Exif WhiteBalance

**URL:** <https://discourse.gohugo.io/t/exif-whitebalance/32900>\
**Category:** support\
**Created:** [May 15, 2021, 3:13pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900 "2021-05-15T15:13:46Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 3:13pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/1 "2021-05-15T15:13:46Z")

</div>

hugo exif tags doesn’t have a tag for WhiteBalance. I don’t know which library it is using to process exif on page but it is not returning any value for following code:

```
            {{ if .Tags.WhiteBalance }}
                <div class="exif">
                    <i class="fa fa-lightbulb"></i> White Balance: 
                    {{ .Tags.WhiteBalance }}
                </div>
            {{ end }}

```

I have checked with exifTool, data for White Balance is there. When I output all .Tags it doesn’t have Tag for WhiteBalance. So just curious if it is there in the library that hugo is using or am I missing something.

All other tags that I need are working properly but lot of tags are missing, very basic ones.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 15, 2021, 3:19pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/2 "2021-05-15T15:19:50Z")

</div>

Add this to your site configuration file:

```auto
[imaging.exif]
includeFields = ".*"

```

See [https://gohugo.io/content-management/image-processing/#image-processing-config](https://gohugo.io/content-management/image-processing/#image-processing-config)

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 3:22pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/3 "2021-05-15T15:22:13Z")

</div>

oh, I read it and missed it, sorry, let me check it…  
thanks for the early reply.

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 3:39pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/4 "2021-05-15T15:39:27Z")

</div>

other tags are working now but WhiteBalance is still not working. Do I need to format the output of the tag? It has a numeric value, but it is not even displaying it.

I changed code to this:

```
            {{ if .Tags.WhiteBalance }}
                <div class="exif">
                    <i class="fa fa-lightbulb"></i> White Balance: 
                    {{ .Tags.WhiteBalance }} {{ .Format "." }}
                </div>
            {{ end }}

```

all most all other tags are working individually, but whitebalance displays only as a part of the display all tags but not individually. when i display all tags it correctly shows 16 as value but individually it returns no value. strange.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 15, 2021, 3:49pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/5 "2021-05-15T15:49:58Z")

</div>

What do you see when you do this?

```auto
{{ $image := resources.Get "foo" }}
{{ with $image.Exif }}
  {{ range $k, $v := .Tags }}
    {{ $k }} = {{ $v }}<br>
  {{ end }}
{{ end }}

```

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 4:03pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/6 "2021-05-15T16:03:17Z")

</div>

yes, i tried that and output is as expected:

Date: 2021-04-16 18:11:07 +0000 UTC Lat/Long: 0/0 Tags: TAG: ApertureValue: 2.27 TAG: BrightnessValue: 4.26 TAG: ColorSpace: 1 TAG: ComponentsConfiguration: TAG: DateTime: 2021-04-16 18:11:07 +0000 UTC TAG: DateTimeDigitized: 2021-04-16 18:11:07 +0000 UTC TAG: DateTimeOriginal: 2021-04-16 18:11:07 +0000 UTC TAG: ExifIFDPointer: 193 TAG: ExifVersion: 0220 TAG: ExposureMode: 0  
TAG: ExposureProgram: 0 TAG: ExposureTime: 1/50 TAG: FNumber: 2.2 TAG: Flash: 16 TAG: FlashpixVersion: 0100 TAG: FocalLength: 6.605 TAG: FocalLengthIn35mmFilm: 7 TAG:  
GPSInfoIFDPointer: 674 TAG: ISOSpeedRatings: 58 TAG: InteroperabilityIFDPointer: 644 TAG: InteroperabilityIndex: R98 TAG: Make: vivo TAG: MeteringMode: 2 TAG: Model: vivo 1906 TAG:  
PixelXDimension: 3120 TAG: PixelYDimension: 4160 TAG: ResolutionUnit: 2 TAG: SceneCaptureType: 0 TAG: SceneType: TAG: SensingMethod: 0 TAG: ShutterSpeedValue: 5.643 TAG: Software: Hypocam TAG:  
SubSecTime: 137022 TAG: SubSecTimeDigitized: 137022 TAG: SubSecTimeOriginal: 137022 TAG: ThumbJPEGInterchangeFormat: 774 TAG: ThumbJPEGInterchangeFormatLength: 7311 TAG: WhiteBalance: 0  
TAG: XResolution: 72 TAG: YCbCrPositioning: 1 TAG: YResolution: 72

but WhiteBalance tag is not displaying individually.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 15, 2021, 4:08pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/7 "2021-05-15T16:08:33Z")

</div>

> WhiteBalance: 0

The zero is an integer, not a string. You can verify with:

```auto
{{ printf "%T" $image.Exif.Tags.WhiteBalance }}

```

So this:

```auto
{{ if $image.Exif.Tags.WhiteBalance }}
  DO SOMETHING
{{ else }}
  DO NOT DO ANYTHING
{{ end }}

```

Produces:

```plaintext
DO NOT DO ANYTHING

```

When using `if` or `with` zero, false, and the empty string are all falsey.

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 4:15pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/8 "2021-05-15T16:15:59Z")

</div>

that is happening with all .Tags that return boolean values. like ExposureMode is also not working as it returns integer. need to change code than. thanks for your help, not familiar with hu/go code that much.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 15, 2021, 4:19pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/9 "2021-05-15T16:19:43Z")

</div>

You can use `isset` to see if a value has been set, even if it falsey.

```auto
{{ if isset $image.Exif.Tags "WhiteBalance" }}
  DO SOMETHING
{{ else }}
  DO NOT DO ANYTHING
{{ end }}

```

Produces:

```nohighlight
DO SOMETHING

```

regardless of what the value is.

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 4:21pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/10 "2021-05-15T16:21:59Z")

</div>

one more thing, it returns 0 and 1 as values. I want to convert 0: Auto and 1: Manual for display. what would be the easiest way to do that? edit existing exif.html shortcode template?

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 15, 2021, 4:35pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/11 "2021-05-15T16:35:42Z")

</div>

ok, working now. thanks for you help. just need to change boolean values to text for display now. is there any tutorial guide for that which i can follow.

Thank you.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 15, 2021, 4:47pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/12 "2021-05-15T16:47:13Z")

</div>

```auto
{{ $whiteBalance := "Auto" }}
{{ if $image.Exif.Tags.WhiteBalance }}
  {{ $whiteBalance = "Manual" }}
{{ end }}

```

There are several tutorials available. Some that come to mind are:

- [https://zwbetz.com/make-a-hugo-blog-from-scratch/](https://zwbetz.com/make-a-hugo-blog-from-scratch/)
- [https://gohugo.io/getting-started/quick-start/](https://gohugo.io/getting-started/quick-start/)
- [https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpOnyRlyS-liKL5ReHDcj4G3](https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpOnyRlyS-liKL5ReHDcj4G3)

The last one is a bit dated, but still quite valuable.

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 17, 2021, 3:13pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/13 "2021-05-17T15:13:23Z")

</div>

thanks for the links, i am using it for a while so familiar with basic settings. but if statements are not working for me somehow.

i have following code:

```
            {{ if isset .Tags "ExposureMode" }}
                <div class="exif">
                    <i class="fa fa-lightbulb"></i> Exposure Mode: {{ .Tags.ExposureMode}}
                    {{ if $ExposureMode := "0" }} Auto
                    {{ else if $ExposureMode := "1" }} Manual
                    {{ else }} Auto bracket
                  {{ end }}
                </div>
                {{ else }}
                {{ end }}

```

which gives me output like:

0 Auto  
1 Auto  
2 Auto

instead of

0 Auto  
1 Manual  
2 Auto Bracket

following tut here: [Conditionals | Hugo | Mike Dane](https://www.mikedane.com/static-site-generators/hugo/conditionals/)

are there any good cheatsheets or manuals for hugo coding so that i can get familiar with it, printable pdf would be handy for reference.

---

<div class="post-metadata">

**Author:** ![chrillek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chrillek/32/19797_2.png) [@chrillek](https://discourse.gohugo.io/u/chrillek)\
**Post date:** [May 17, 2021, 3:22pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/14 "2021-05-17T15:22:16Z")

</div>

You’re assigning (`:=`), not testing for equality.

---

<div class="post-metadata">

**Author:** ![null](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/null/32/13742_2.png) [@null](https://discourse.gohugo.io/u/null)\
**Post date:** [May 17, 2021, 4:05pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/15 "2021-05-17T16:05:57Z")

</div>

ok, thanks it is working now with following code:

```
            {{ if isset .Tags "ExposureMode" }}
                <div class="exif">
                    <i class="fa fa-lightbulb"></i> Exposure Mode: {{ .Tags.ExposureMode}}
                    {{ if eq .Tags.ExposureMode 0 }} Auto
                    {{ else if eq .Tags.ExposureMode 1 }} Manual
                    {{ else }} Auto bracket
                  {{ end }}
                </div>
                {{ else }}
                {{ end }}

```

is there a more efficient way to do this?

thanks for your reply.

---

<div class="post-metadata">

**Author:** ![chrillek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chrillek/32/19797_2.png) [@chrillek](https://discourse.gohugo.io/u/chrillek)\
**Post date:** [May 17, 2021, 4:55pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/16 "2021-05-17T16:55:24Z")

</div>

> [@null](#):
>
> is there a more efficient way to do this?

Firstly, why? Do you think that build time is long because of _this_?  
Secondly, you could slim it down a bit with `with`:

```auto
{{with .Tags.ExposureMode}} 
{{ if eq . 1}} Manual {{/* ExposureMode eq 1 */}}
{{ else}} Auto bracket {{/* ExposureMode neither 0 nor 1 */}}
{{end}}
{{ else}} Auto {{/* ExposureMode 0 */}}
{{end}}

```

`with` is true in this context for all values not equal zero, so you only have to test dot for 1 in the `if`(dot is set to `.Tags.ExposureMode` by the `with`). The `else` inside the `if` is always true if ExposureMode is neither 1 nor 0, and finally the last `else` is true if ExposureMode is 0 (because then `with` is false).  
If you only have the values 0, 1 and 2, you could probably use a slice like so

```auto
{{ $modes := slice "Auto" "Manual" "Auto bracket"}}
{ {if isset .Tags "ExposureMode" }} 
...
{{index $modes .Tags.ExposureMode}}
...

```

I hope 😉  
And there might be other ways. But I’m still wondering if this piece of code merits optimisation.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [May 19, 2021, 4:56pm UTC](https://discourse.gohugo.io/t/exif-whitebalance/32900/17 "2021-05-19T16:56:23Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
