{"id":2768,"date":"2023-09-30T23:38:49","date_gmt":"2023-09-30T15:38:49","guid":{"rendered":"https:\/\/www.tra56.com\/?p=2768"},"modified":"2023-09-30T23:38:49","modified_gmt":"2023-09-30T15:38:49","slug":"2768","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/2768.html","title":{"rendered":"php\u5c06png\u56fe\u6807\u4e0e\u80cc\u666f\u56fe\u5408\u5e76\u65f6\uff0c\u56fe\u6807\u56db\u5468\u4e3a\u9ed1\u8272\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"
    \r\n    public function addimgtobg($srcurl, $desurl)\r\n    {\r\n \r\n        \/\/\u521b\u5efa\u6e90\u56fe\u7684\u5b9e\u4f8b\r\n        $src = imagecreatefromstring(file_get_contents($srcurl));\r\n        \/\/\u521b\u5efapng\u56fe\u7684\u5b9e\u4f8b\r\n        $des = imagecreatefrompng($desurl);\r\n        \/\/\u83b7\u53d6\u70b9\u56fe\u7247\u7684\u5bbd\u9ad8\r\n        list($point_w, $point_h) = getimagesize($desurl);\r\n \r\n        \/\/\u91cd\u70b9\uff1apng\u900f\u660e\u7528\u8fd9\u4e2a\u51fd\u6570\r\n        imagecopy($src, $des, 970, 1010, 0, 0, $point_w, $point_h);\r\n        imagecopy($src, $des, 930, 1310, 0, 0, $point_w, $point_h);\r\n \r\n \r\n        $filepath = date('Ymd') . DS . time() . '.jpg';\r\n        imagejpeg($src, 'uploads' . DS . $filepath);\r\n        imagedestroy($src);\r\n        imagedestroy($des);\r\n        return $filepath;\r\n    }<\/pre>\n

<\/p>\n","protected":false},"excerpt":{"rendered":"

         public […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,92],"tags":[],"class_list":["post-2768","post","type-post","status-publish","format-standard","hentry","category-php","category-phpcode"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/2768"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=2768"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/2768\/revisions"}],"predecessor-version":[{"id":2769,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/2768\/revisions\/2769"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=2768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=2768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=2768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}