php-gd

Creating PNG thumbnail using PHP

孤人 提交于 2021-02-19 08:20:28
问题 I'm trying to create a thumbnail image it returned an error, that imagecopyresized() expects 2 parameter to be resource, but it can create the image but the output is only a small black image. here is my code $image = "asd.PNG"; $image_size = getimagesize($image); $image_width = $image_size[0]; $image_height = $image_size[1]; $new_size = ($image_width + $image_height)/($image_width*($image_height/45)); $new_width = $image_width * $new_size; $new_height = $image_height * $new_size; $new_image

How to add php gd extension to Dockerfile

扶醉桌前 提交于 2020-08-24 08:23:32
问题 I'm getting this error when trying to deploy using alpine: phpoffice/phpspreadsheet 1.2.1 requires ext-gd * -> the requested PHP extension gd is missing from your system. Here's my Dockerfile: FROM php:7.2-alpine RUN apk update RUN apk add zlib-dev gd php7-gd RUN docker-php-ext-install sockets pdo_mysql zip RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd The error is an output from a jenkins run. I think it's failing somewhere around here... build: docker run --rm --tty

How to add php gd extension to Dockerfile

北慕城南 提交于 2020-08-24 08:23:11
问题 I'm getting this error when trying to deploy using alpine: phpoffice/phpspreadsheet 1.2.1 requires ext-gd * -> the requested PHP extension gd is missing from your system. Here's my Dockerfile: FROM php:7.2-alpine RUN apk update RUN apk add zlib-dev gd php7-gd RUN docker-php-ext-install sockets pdo_mysql zip RUN apk add --no-cache libpng libpng-dev && docker-php-ext-install gd The error is an output from a jenkins run. I think it's failing somewhere around here... build: docker run --rm --tty

Centering text in php image

99封情书 提交于 2020-08-11 15:06:11
问题 I'm not sure how I can center text in a php-created image using imagettftext. Here's my code: header('Content-Type: image/png'); $im = imagecreatetruecolor(260, 180); $background = imagecolorallocate($im, 0, 0, 255); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 60, 153, 181); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 200, $white); $text = $_GET['tname']; $font = 'OpenSans-Semibold.ttf'; imagettftext($im, 20, 0, $x+1, $y

imagecreatefrompng is not working at all

不羁的心 提交于 2020-05-25 07:16:54
问题 I already checked the file with mime type. If it is jpg or gif it is working perfectly with $src = imagecreatefromjpeg($tmpName); and $src = imagecreatefromgif($tmpName); but if the image is png $src = imagecreatefrompng($tmpName) ; src variable is empty in the png case, but in jpg and gif it is showing it's resource id . would someone tell me what i need to do? $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $_FILES['photo']['tmp_name']); unset($_FILES["photo"]["type"]);

Unable to locate package php7.3-gd

久未见 提交于 2020-02-22 08:12:08
问题 I get the error from my cakephp 2.x project: The PHP GD extension is required, but is not installed. I use php7.3 with apache on debian I search and find apt-get install php7.3-gd I tried this but i only get following error: E: Unable to locate package php7.3-gd E: Couldn't find any package by glob 'php7.3-gd' E: Couldn't find any package by regex 'php7.3-gd' I searched again, but didnt find a soulution for this problem only for ubunto and nothing else worked. I hope someone could help me

Unable to locate package php7.3-gd

妖精的绣舞 提交于 2020-02-22 08:09:47
问题 I get the error from my cakephp 2.x project: The PHP GD extension is required, but is not installed. I use php7.3 with apache on debian I search and find apt-get install php7.3-gd I tried this but i only get following error: E: Unable to locate package php7.3-gd E: Couldn't find any package by glob 'php7.3-gd' E: Couldn't find any package by regex 'php7.3-gd' I searched again, but didnt find a soulution for this problem only for ubunto and nothing else worked. I hope someone could help me

Unable to locate package php7.3-gd

大憨熊 提交于 2020-02-22 08:08:58
问题 I get the error from my cakephp 2.x project: The PHP GD extension is required, but is not installed. I use php7.3 with apache on debian I search and find apt-get install php7.3-gd I tried this but i only get following error: E: Unable to locate package php7.3-gd E: Couldn't find any package by glob 'php7.3-gd' E: Couldn't find any package by regex 'php7.3-gd' I searched again, but didnt find a soulution for this problem only for ubunto and nothing else worked. I hope someone could help me

PHP - Compress Image to Meet File Size Limit

五迷三道 提交于 2020-01-11 07:55:27
问题 I have to upload image files that meet a max width dimension and max file size. I have the code that checks width size and resizes the image to meet the max image width. However, when I am saving the file I can set the quality imagejpeg( $imgObject , 'resized/50.jpg' , 50 ); //save image and set quality What I would like to do is avoid setting a standard quality, as the images being submitted vary highly from quality and may be low to begin with. The quality of the image should be set as high

PHP Fatal error: Call to undefined function imagettftext()

自古美人都是妖i 提交于 2020-01-09 06:51:48
问题 Why am I getting the error PHP Fatal error: Call to undefined function imagettftext() on line 29? <?php ob_start(); session_start(); $strings = '123456789'; $i = 0; $characters = 6; $code = ''; while ($i < $characters) { $code .= substr($strings, mt_rand(0, strlen($strings)-1), 1); $i++; } $_SESSION['captcha'] = $code; //generate image $im = imagecreatetruecolor(124, 40); $foreground = imagecolorallocate($im, 0, 0, 0); $shadow = imagecolorallocate($im, 173, 172, 168); $background =