EXIF display truncates shutter speed instead of rounding #1722

Open
opened 2026-10-05 00:54:12 +02:00 by adam · 2 comments
Owner

I recently made a discovery on my Canon R6: the shutter speed EXIF data that is saved is not exactly the same as the shutter speed that is set. For example, a recent photo I took at a shutter speed of 1/640 is saved by the camera as 104858/67109119 (!), which is equal to 1/639.999990463. That's pretty close to 1/640, and most EXIF utilities I've used on the photo report 1/640. But in my Piwigo gallery, it's reported as 1/639, so I think that Piwigo must be truncating that denominator instead of rounding up. That looks odd, and it would be nice if it could show 1/640. For example:

https://www.daveguertin.net/picture.php?/8292/category/all

Or is there a setting somewhere that I could change?

I recently made a discovery on my Canon R6: the shutter speed EXIF data that is saved is not exactly the same as the shutter speed that is set. For example, a recent photo I took at a shutter speed of 1/640 is saved by the camera as 104858/67109119 (!), which is equal to 1/639.999990463. That's pretty close to 1/640, and most EXIF utilities I've used on the photo report 1/640. But in my Piwigo gallery, it's reported as 1/639, so I think that Piwigo must be truncating that denominator instead of rounding up. That looks odd, and it would be nice if it could show 1/640. For example: https://www.daveguertin.net/picture.php?/8292/category/all Or is there a setting somewhere that I could change? <!-- github-sync-id:1877483214 -->
Author
Owner

I think that your rounding issue is resolved by a small change to the 'Exif View' plugin that I assume you are using. I have modified line 129 of the default coding of file /.../piwigo/plugins/exif_view/main.inc.php as follows ;-

 //         return '1/'.floor(1/($tokens[0]/$tokens[1])).' s';
            return '1/'.round(1/($tokens[0]/$tokens[1])).' s';

Note that I have commented out the original line and then inserted the amended line. This makes it easier to undo the change if it fails. I don't wish to insult your training. It's just that I have no expertise in coding!

I downloaded your picture to my site to test this change. I took the attached screenshot and then purged your picture from my site.
Great picture, by the way. I'm also using the R6 but I don't have the L Series lens.
Screenshot 2023-11-27 at 14 30 39

I think that your rounding issue is resolved by a small change to the 'Exif View' plugin that I assume you are using. I have modified line 129 of the default coding of file /.../piwigo/plugins/exif_view/main.inc.php as follows ;- ``` // return '1/'.floor(1/($tokens[0]/$tokens[1])).' s'; return '1/'.round(1/($tokens[0]/$tokens[1])).' s'; ``` Note that I have commented out the original line and then inserted the amended line. This makes it easier to undo the change if it fails. I don't wish to insult your training. It's just that I have no expertise in coding! I downloaded your picture to my site to test this change. I took the attached screenshot and then purged your picture from my site. Great picture, by the way. I'm also using the R6 but I don't have the L Series lens. <img width="601" alt="Screenshot 2023-11-27 at 14 30 39" src="https://github.com/Piwigo/Piwigo/assets/152191693/6d951660-cf7c-48bb-a178-00db9f4707a8"> <!-- github-comment-id:1828018745 -->
Author
Owner

Thanks for the tip! That worked fine.

Thanks for the tip! That worked fine. <!-- github-comment-id:1828774671 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1722