我必须在新的浏览器窗口中打开图像,但是要用更大的尺寸。
我使用下面的代码:
<a href="<?php echo $prodata['Product']['imgurl1'];?>" target="_blank">
<img src="<?php echo $data['Product']['imgurl'];?>" alt="Img 1" width="374" height="279" id="bigimage" title="<?php echo $prodata['Product']['img1desc'];?>" style="border:1px solid #CCCCCC"/>
</a>
问题是我需要在新的浏览器窗口中打开的图像应该是更大的尺寸
有谁能帮帮我吗?谁能告诉我如何使用timthumb与cakephp
您可以像这样格式化CakePHP代码来显示链接的图像:
echo $this->Html->link(
$this->Html->Image(
$data['Product']['imgurl'],
array(
'alt' => 'Img 1',
'width' => '374',
'height' => '279',
'id' => 'bigimage',
'title' => $prodata['Product']['img1desc'],
'style' => 'border:1px solid #CCCCCC',
)
),
$proddata['Product']['imgurl1'],
array('target' => '_blank')
);
看这个答案:(使用标准PHP)
$source_image = imagecreatefromjpeg('/image/path.jpg'); // Open the image
$source_imagex = imagesx($source_image);
$source_imagey = imagesy($source_image);
$dest_imagex = 300; // New size
$dest_imagey = 200;
$image2 = imagecreatetruecolor($dest_imagex, $dest_imagey);
imagecopyresampled($image2, $source_image, 0, 0, 0, 0,
$dest_imagex, $dest_imagey, $source_imagex, $source_imagey);
imagejpeg($image2, '/new/image.jpg', 100); // Save the new Image
你可以用png或php支持的任何格式替换jpeg。
如果你直接链接到图片,浏览器将以原始尺寸显示。