【发布时间】:2015-01-19 20:22:17
【问题描述】:
我想将 Google 地图图像保存到我的服务器。下面是我用来获取和保存这些图像的代码,以及用于创建缩略图的代码。我正在为此使用 CodeIgniter。
//saving original image on server
$post = $_POST;
$file = file_get_contents("http://maps.google.com/maps/api/staticmap?size=".$post['w']."x".$post['h']."&sensor=false&markers=color:red|size:mid|".$post['lt'].",".$post['lg']."&&zoom=".$post['z']);
$filename = 'map_'.uniqid().'.png';
$name = './assets/images/upload/'.$filename;
file_put_contents($name, $file);
// creating thumbnail
$config_manip = array(
'image_library' => 'gd2',
'source_image' => './assets/images/upload/'.$filename,
'new_image' => './assets/images/upload/thumb_'.$filename,
'maintain_ratio' => false,
'quality' => "10%",
'width' => 480,
'height' => 480
);
$this->load->library('image_lib', $config_manip);
$this->image_lib->resize();
我的问题是生成的缩略图比原始图像大得多。比较:
为什么缩略图比原图大?
【问题讨论】:
-
呃。原稿为 640×640。缩略图为 480×480。我无法达到您的预期。
-
因为 480
-
请注意,您正在尝试做的是违反地图 TOS developers.google.com/maps/terms 10.1.3。
标签: php image google-maps