简体   繁体   中英

increase size of image and superimpose on transparent image using gd library php

I will get an image from frontend and I want to increase the size of image and copy that image on transparent layout. I want this because i simply want my image to appear 5 times larger than its original size.

$frontimgheight=$frontfeatures['height'];
$frontimgwidth=$frontfeatures['width'];
$frontimgheightnew=$frontimgheight*10;
$frontimgwidthnew=$frontimgwidth*10;

// create transparent layout
$thumbfront = imagecreate($frontimgwidthnew, $frontimgheightnew);
$color = imagecolorallocatealpha($thumbfront, 0, 0, 0, 127);
imagefill($thumbfront, 0, 0, $color);


$dbfrontimg=imagecreatefrompng("./uploads/".$frontimg);
//$dbbackimg=imagecreatefrompng("./uploads/".$backimg);

imagecopyresized($thumbfront, $dbfrontimg, 0, 0, 0, 0,$frontimgwidthnew, $frontimgheightnew, $frontimgwidth, $frontimgheight);
header('Content-Type: image/png');
imagepng($thumbfront);

Above code simply gives transparent image of 800 x 1000 pixels.

I want my frontend image to be overlapped on transparent layout.

Here is a library I wrote to do stuff like this: https://github.com/Pamblam/EasyImage

You can resize the image and send it back to the browser in one line:

echo EasyImage::Create("./uploads/".$frontimg)
    ->resize($newWidth, $newHeight);

You can also do overlays and all kinds of other fancy stuff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM