Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从url调整图像大小并使图像的大小变小_Php_Image_Url_Joomla_Resize - Fatal编程技术网

Php 如何从url调整图像大小并使图像的大小变小

Php 如何从url调整图像大小并使图像的大小变小,php,image,url,joomla,resize,Php,Image,Url,Joomla,Resize,我有一个带有virtuemart模块的joomla网站 我拥有的是托管在其他域上的图像和缩略图 Virtuemart为我提供了两个选项: 1-浏览图像,将自动创建缩略图 2-输入外部托管图像的URL,此选项没有调整大小选项 我克服这个问题的方法(当然是在帮助下)是为img标签设置height=“”属性。唯一的问题是,当加载大图像时,即:500 x 700 px,所谓的缩略图加载需要时间,这是合乎逻辑的 有人能给我一个选项,如何从一个url图像可以“调整大小”,作为结果,缩略图需要较少的时间加载

我有一个带有virtuemart模块的joomla网站

我拥有的是托管在其他域上的图像和缩略图

Virtuemart为我提供了两个选项:

1-浏览图像,将自动创建缩略图

2-输入外部托管图像的URL,此选项没有调整大小选项

我克服这个问题的方法(当然是在帮助下)是为img标签设置height=“”属性。唯一的问题是,当加载大图像时,即:500 x 700 px,所谓的缩略图加载需要时间,这是合乎逻辑的

有人能给我一个选项,如何从一个url图像可以“调整大小”,作为结果,缩略图需要较少的时间加载

就我个人而言,我正在考虑一种方法来降低大小调整后的图像的图像质量,该图像来自带有代码、css或其他任何内容的url

我知道这与解决代码关系不大,但我知道你们知道的选项比我多。

你们可以利用PHP的函数

示例程序(源代码:php.net)



当然可以,我已经在帖子中添加了一个例子@bzabi,请您看看我的下一个问题,它涉及到您给我的代码。[ [1]:
<?php
// The file
$filename = 'http://valplibrary.files.wordpress.com/2009/01/5b585d_merry-christmas-blue-style.jpg';
$percent = 0.5; // percentage of resize

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 100);
?>