PHP GDによる画像の拡大と縮小




ImageCopyResampled/ CMS

ImageCopyResized ImageCopyResizedImageCopyResampled ImageCopyResized


bool
ImageCopyResampled(resource $dst_image, resource $src_image,
    int $dst_x, int $dst_y, int $src_x, int $src_y,
    int $dst_w, int $dst_h, int $src_w, int $src_h )

bool
ImageCopyResized(resource $dst_image, resource $src_image,
    int $dst_x, int $dst_y, int $src_x, int $src_y,
    int $dst_w, int $dst_h, int $src_w, int $src_h )



ImageCopyResampled


<?php
$img = ImageCreateFromJPEG('sample0.jpg');

$width = ImageSx($img);
$height = ImageSy($img);

$out = ImageCreateTrueColor($width/2, $height/2);
ImageCopyResampled($out, $img,
    0,0,0,0, $width/2, $height/2, $width, $height);

header('Content-Type: image/jpeg');
ImageJPEG($out);
?>


動作例



<img src="script/resize1.php">



元画像

IPv6基礎検定

YouTubeチャンネルやってます!