【问题标题】:Resize image using another website使用其他网站调整图像大小
【发布时间】:2015-12-30 10:00:39
【问题描述】:

已经用尽了解决我在Problems rotating and resizing large images 中发布的图像大小调整问题的可能性,因为我有一个共享服务器,我无法在其上更改内存限额或安装额外的图像处理库,我想知道是否会有我如何使用外部网站调整图像大小并将其传回我的 PHP 脚本?

例如:

$mylargeimage = "http://www.mywebsite.com/uploads/largephoto.jpg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imageresizingsite.com/resizethis.php?src=" . $mylargeimage . "&scale=50");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true)

$output = curl_exec($ch);
curl_close($ch);

我不知道这是否可行 - 我也没有找到一个可以实际调整图像大小的网站 - 但这种方法是否可行,有人知道使用这种方法调整图像大小的网站吗?

【问题讨论】:

    标签: php


    【解决方案1】:

    如果您想自己调整图像大小,请尝试以下操作: (我现在无法测试代码,我目前没有本地服务器)

    $image = $link_to_image;
    $source_image = imagecreatefromfile($image);
    $source_imagex = imagesx($source_image);
    $source_imagey = imagesy($source_image);
    $crop_measure = min($source_imagex, $source_imagey);
    
    
    $to_crop_array = array('x' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure);
    $thumb_im = imagecrop($source_image, $to_crop_array);
    
    imagejpeg($thumb_im, NULL, 80); //This may change, see the link below in this answer to see the right way to do that (it change because of extension) 
    }
    
    ?>
    

    Link that maybe help you

    请记住,如果您需要从 php 调整图像大小,您应该在服务器上安装 gd 驱动程序,查看是否有它们,在空白页面中调用 php_info()

    如果您想远程执行此操作 THIS SHOULD HELP YOU

    【讨论】:

    • 谢谢,但不幸的是我遇到了同样的问题,即我在服务器上没有足够的可用内存来操作图像,并且我无法增加内存限额,因为它是共享服务器.
    • 希望对您有所帮助!如果您更喜欢在另一个“站点”上执行此操作,请尝试在网络上搜索“image resizer api”
    猜你喜欢
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    • 1970-01-01
    • 2013-01-05
    • 2015-10-16
    • 1970-01-01
    相关资源
    最近更新 更多