{"id":664,"date":"2006-07-28T02:00:00","date_gmt":"2006-07-27T17:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2006-07-28-2.html"},"modified":"2006-07-28T02:00:00","modified_gmt":"2006-07-27T17:00:00","slug":"2006-07-28-2","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2006-07-28-2.html","title":{"rendered":"imagerotate \u306e\u5c0f\u6570\u304b\u3089\u6574\u6570\u3078\u306e\u5909\u63db\u4ed5\u69d8"},"content":{"rendered":"<p>\nimagerotate \u306e\u7d50\u679c\u3092\u8a08\u7b97\u3067\u51fa\u3057\u305f\u3044\u306a\u3068\u601d\u3044\u6b21\u306e\u30b3\u30fc\u30c9\u3067\u691c\u8a3c\u3057\u3066\u307f\u307e\u3057\u305f\u3002\n<\/p>\n<blockquote><p>&lt;?php<br \/>\n\/\/ \u5bfe\u8c61\u306e\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3002<br \/>\n$sw = 1000;<br \/>\n$sh = 2000;<br \/>\n\/\/ \u5b9f\u6e2c\u7528\u306b\u753b\u50cf\u751f\u6210<br \/>\n$im = imagecreatetruecolor($sw,$sh);<br \/>\nfor($deg = -360; $deg <= 360; $deg +=15){<br \/>\n&nbsp;&nbsp;&nbsp;$rad = deg2rad($deg); \/\/ \u4e09\u89d2\u95a2\u6570\u306f\u30e9\u30b8\u30a2\u30f3\u3092\u53d6\u308b\u306e\u3067\u89d2\u5ea6\u3092\u30e9\u30b8\u30a2\u30f3\u306b\u5909\u63db<br \/>\n&nbsp;&nbsp;&nbsp;\/\/ \u56de\u8ee2\u5f8c\u306e\u30b5\u30a4\u30ba\u8a08\u7b97(\u56db\u6368\u4e94\u5165)<br \/>\n&nbsp;&nbsp;&nbsp;$w = round(abs($sw * cos($rad)) + abs($sh * sin($rad)));<br \/>\n&nbsp;&nbsp;&nbsp;$h = round(abs($sw * sin($rad)) + abs($sh * cos($rad)));<br \/>\n&nbsp;&nbsp;&nbsp;\/\/ \u5b9f\u969b\u306b\u56de\u8ee2\u3055\u305b\u305f\u6642\u306e\u30b5\u30a4\u30ba<br \/>\n&nbsp;&nbsp;&nbsp;$im_t =imagerotate($im, $deg, -1);<br \/>\n&nbsp;&nbsp;&nbsp;$rw = imagesx($im_t);<br \/>\n&nbsp;&nbsp;&nbsp;$rh = imagesy($im_t);<br \/>\n&nbsp;&nbsp;&nbsp;imagedestroy($im_t);<br \/>\n&nbsp;&nbsp;&nbsp;\/\/ \u6bd4\u8f03<br \/>\n&nbsp;&nbsp;&nbsp;if($w != $rw || $h != $rh){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &#8220;$deg: calc($w, $h) != real($rw, $rh) &#8220;.&#8221;\\n&#8221;; <br \/>\n&nbsp;&nbsp;&nbsp;}<br \/>\n}<br \/>\n?&gt;\n<\/p><\/blockquote>\n<p>\u7d50\u679c:\n<\/p>\n<blockquote><p>-330: calc(1866, 2232) != real(1867, 2233)<br \/>\n-315: calc(2121, 2121) != real(2122, 2122)<br \/>\n-300: calc(2232, 1866) != real(2233, 1867)<br \/>\n-240: calc(2232, 1866) != real(2233, 1867)<br \/>\n-225: calc(2121, 2121) != real(2122, 2122)<br \/>\n-210: calc(1866, 2232) != real(1867, 2233)<br \/>\n-150: calc(1866, 2232) != real(1867, 2233)<br \/>\n-135: calc(2121, 2121) != real(2122, 2122)<br \/>\n-120: calc(2232, 1866) != real(2233, 1867)<br \/>\n-60: calc(2232, 1866) != real(2233, 1867)<br \/>\n-45: calc(2121, 2121) != real(2122, 2122)<br \/>\n-30: calc(1866, 2232) != real(1867, 2233)<br \/>\n30: calc(1866, 2232) != real(1867, 2233)<br \/>\n45: calc(2121, 2121) != real(2122, 2122)<br \/>\n60: calc(2232, 1866) != real(2233, 1867)<br \/>\n120: calc(2232, 1866) != real(2233, 1867)<br \/>\n135: calc(2121, 2121) != real(2122, 2122)<br \/>\n150: calc(1866, 2232) != real(1867, 2233)<br \/>\n210: calc(1866, 2232) != real(1867, 2233)<br \/>\n225: calc(2121, 2121) != real(2122, 2122)<br \/>\n240: calc(2232, 1866) != real(2233, 1867)<br \/>\n300: calc(2232, 1866) != real(2233, 1867)<br \/>\n315: calc(2121, 2121) != real(2122, 2122)<br \/>\n330: calc(1866, 2232) != real(1867, 2233)\n<\/p><\/blockquote>\n<p>\u3053\u306e\u7d50\u679c\u304b\u3089\u5224\u65ad\u3057\u3066\u3001<br \/>\nimagerotate \u3067\u306f\u5185\u90e8\u7684\u306b ceil \u3067\u7e70\u308a\u4e0a\u3052\u306b\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067<br \/>\n\u5358\u7d14\u306b round -> ceil \u306b\u304b\u3048\u3066\u307f\u305f\u3068\u3053\u308d\u3001<br \/>\n\u7d50\u679c\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\n<\/p>\n<blockquote><p>-360: calc(1001, 2001) != real(1000, 2000)<br \/>\n-270: calc(2001, 1001) != real(2000, 1000)<br \/>\n-180: calc(1001, 2001) != real(1000, 2000)<br \/>\n-90: calc(2000, 1001) != real(2000, 1000)\n<\/p><\/blockquote>\n<p>PHP \u306e float \u306e\u7279\u6027(*1)\u304c\u60aa\u3055\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u3001\u5207\u308a\u4e0a\u3052\u51e6\u7406\u3067 GD \u306e\u7d50\u679c\u3068\u98df\u3044\u9055\u3044\u304c\u3067\u304d\u3066\u3057\u307e\u3063\u305f\u3088\u3046\u3067\u3059\u3002<br \/>\n\u3068\u3044\u3046\u3053\u3068\u3067\u6b21\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u5b8c\u5168\u306b\u4e00\u81f4\u3057\u307e\u3057\u305f\u3002\n<\/p>\n<blockquote><p>&lt;?php<br \/>\n\/\/ \u56de\u8ee2\u5f8c\u306e\u30b5\u30a4\u30ba\u8a08\u7b97(imagerotate \u4e92\u63db\u306e\u5207\u308a\u4e0a\u3052)<br \/>\n$fw = abs($sw * cos($rad)) + abs($sh * sin($rad));<br \/>\n$w = ceil(&#8220;$fw&#8221;); \/\/ \u4e00\u5ea6\u6587\u5b57\u5217\u306b\u3059\u308b<br \/>\n$fh = abs($sw * sin($rad)) + abs($sh * cos($rad));<br \/>\n$h = ceil(&#8220;$fh&#8221;); \/\/ \u540c\u4e0a\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n&nbsp;*1: PHP \u306e float \u306f\u6709\u52b9\u6841\u6570\u3092\u8d85\u3048\u308b\u3068\u8868\u793a\u4e0a\u305d\u306e\u90e8\u5206\u304c\u898b\u3048\u306a\u304f\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<blockquote><p>$f = 1 + 1E-13;<br \/>\necho &#8220;$f\\n&#8221;; \/\/ 1 \u304c\u8868\u793a\u3055\u308c\u308b<br \/>\nif($f > 1){<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;echo &#8220;$f > 1\\n&#8221;; \/\/ 1 > 1 \u304c\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n}<br \/>\necho sprintf(&#8220;%.15f&#8221;, $f).&#8221;\\n&#8221;; \/\/ 1.000000000000100 \u304c\u8868\u793a\u3055\u308c\u308b\n<\/p><\/blockquote>\n<p>\n","protected":false},"excerpt":{"rendered":"<p>imagerotate \u306e\u7d50\u679c\u3092\u8a08\u7b97\u3067\u51fa\u3057\u305f\u3044\u306a\u3068\u601d\u3044\u6b21\u306e\u30b3\u30fc\u30c9\u3067\u691c\u8a3c\u3057\u3066\u307f\u307e\u3057\u305f\u3002 &lt;?php \/\/ \u5bfe\u8c61\u306e\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3002 $sw = 1000; $sh = 2000; \/\/ \u5b9f\u6e2c\u7528\u306b\u753b\u50cf\u751f\u6210 $im = im &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2006-07-28-2.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">imagerotate \u306e\u5c0f\u6570\u304b\u3089\u6574\u6570\u3078\u306e\u5909\u63db\u4ed5\u69d8<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[32],"class_list":["post-664","post","type-post","status-publish","format-standard","hentry","tag-php"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=664"}],"version-history":[{"count":0,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/664\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}