{"id":820,"date":"2008-12-15T00:18:11","date_gmt":"2008-12-15T04:18:11","guid":{"rendered":"http:\/\/www.ezrasf.com\/wplog\/?p=820"},"modified":"2008-12-16T22:15:30","modified_gmt":"2008-12-17T02:15:30","slug":"division-issue-in-yapb","status":"publish","type":"post","link":"https:\/\/www.ezrasf.com\/wplog\/2008\/12\/15\/division-issue-in-yapb\/","title":{"rendered":"Division Issue in YAPB"},"content":{"rendered":"<p>Problem PHP in Yet Another Photoblog causes &#8220;<strong>Warning<\/strong>: Division by zero in\u00c2\u00a0<strong>exifReader.inc\u00c2\u00a0<\/strong>on line\u00c2\u00a0<strong>859<span style=\"font-weight: normal;\">&#8221; (the problem line is in bold):<\/span><\/strong><\/p>\n<p>\u00c2\u00a0<\/p>\n<blockquote><p>case TAG_SHUTTERSPEED:<br \/>\n\u00c2\u00a0\u00c2\u00a0\/\/ More complicated way of expressing exposure time, so only use<br \/>\n\u00c2\u00a0\u00c2\u00a0\/\/ this value if we don&#8217;t already have it from somewhere else.<br \/>\n\u00c2\u00a0\u00c2\u00a0if ($this-&gt;ImageInfo[TAG_EXPOSURETIME] == 0){<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0$sp = $this-&gt;ConvertAnyFormat($ValuePtr, $Format);<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\/\/ Temporary Workaround for divizion by zero problem<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0if (!empty($sp[0])) {<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0<strong>$this-&gt;ImageInfo[TAG_SHUTTERSPEED] = (1\/exp($sp[0]*log(2)));<\/strong><br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0} else {<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0$this-&gt;ImageInfo[TAG_SHUTTERSPEED] = 0;<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0 \u00c2\u00a0}<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0}<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0break;<\/p><\/blockquote>\n<p>\u00c2\u00a0<\/p>\n<p>Looks like YAPB is attempting to create a value if one doesn&#8217;t exist for\u00c2\u00a0TAG_EXPOSURETIME by inventing a new value. In my problem picture, the exposure time is\u00c2\u00a00.003 seconds which != 0. So why is the\u00c2\u00a0($this-&gt;ImageInfo[TAG_EXPOSURETIME] == 0)\u00c2\u00a0condition evaluated as true?\u00c2\u00a0<\/p>\n<p>Interestingly, just prior to this is some code dealing with TAG_EXPOSURETIME which seems to be affecting this. Changing the 0.5 to 0.0005 (less than my current value removes the problem.<\/p>\n<blockquote><p>case TAG_EXPOSURETIME:<br \/>\n\u00c2\u00a0\u00c2\u00a0\/\/ Simplest way of expressing exposure time, so I trust it most.<br \/>\n\u00c2\u00a0\u00c2\u00a0\/\/ (overwrite previously computd value if there is one)<br \/>\n\u00c2\u00a0\u00c2\u00a0$tmp = $this-&gt;ConvertAnyFormat($ValuePtr, $Format);<br \/>\n\u00c2\u00a0\u00c2\u00a0$this-&gt;ImageInfo[&#8216;h&#8217;][&#8220;exposureTime&#8221;] = sprintf(&#8220;%6.4f s (%d\/%d)&#8221;,(double)$tmp[0],$tmp[1][0],$tmp[1][1]);<br \/>\n\u00c2\u00a0\u00c2\u00a0<strong>if ($tmp[0] &lt;= 0.5){<br \/>\n\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0$this-&gt;ImageInfo[&#8216;h&#8217;][&#8220;exposureTime&#8221;] .= sprintf(&#8221; (1\/%d)&#8221;,(int)(0.5 + 1\/$tmp[0]));<br \/>\n\u00c2\u00a0\u00c2\u00a0}<\/strong><br \/>\n\u00c2\u00a0\u00c2\u00a0break;<\/p><\/blockquote>\n<p>With this conditional, the exposure time is &#8220;0.003 s\u00c2\u00a0(1\/400)\u00c2\u00a0(1\/400)&#8221; without &#8220;0.003 s (1\/400)&#8221;. Didn&#8217;t see a reason to have it twice, so I&#8217;ve dropped it.<\/p>\n<p>Also, I figure it would be better to call\u00c2\u00a0ImageInfo[&#8216;h&#8217;][&#8220;exposureTime&#8221;] instead of\u00c2\u00a0ImageInfo[TAG_EXPOSURETIME]. With this change, it seems to have resolved the issue for me.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem PHP in Yet Another Photoblog causes &#8220;Warning: Division by zero in\u00c2\u00a0exifReader.inc\u00c2\u00a0on line\u00c2\u00a0859&#8221; (the problem line is in bold): \u00c2\u00a0 case TAG_SHUTTERSPEED: \u00c2\u00a0\u00c2\u00a0\/\/ More complicated way of expressing exposure time, so only use \u00c2\u00a0\u00c2\u00a0\/\/ this value if we don&#8217;t already have it from somewhere else. \u00c2\u00a0\u00c2\u00a0if ($this-&gt;ImageInfo[TAG_EXPOSURETIME] == 0){ \u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0$sp = $this-&gt;ConvertAnyFormat($ValuePtr, $Format); \u00c2\u00a0\u00c2\u00a0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[165],"tags":[457,651,458,460,456,993,459,294,404,461],"class_list":["post-820","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-condition","tag-exif","tag-exposure-time","tag-photoblog","tag-php","tag-rar-archive","tag-shutter-speed","tag-trust","tag-workaround","tag-yapb"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1rUBW-de","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts\/820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/comments?post=820"}],"version-history":[{"count":0,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts\/820\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/media?parent=820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/categories?post=820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/tags?post=820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}