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

Flatten multiple transparent PNGs with PHP GD

喜欢而已 提交于 2021-02-18 18:10:58
问题 I am building a product configuration module which requires that multiple transparent PNGs of the same size (which represent product parts) be flattened onto one image. At first I tried this which made the composition of the 3 images but on a black background: <?php $x = 500; $y = 500; $final_img = imagecreatetruecolor($x, $y); $images = array('1.png', '2.png', '3.png'); foreach ($images as $image) { $image_layer = imagecreatefrompng($image); imagecopy($final_img, $image_layer, 0, 0, 0, 0, $x

Flatten multiple transparent PNGs with PHP GD

僤鯓⒐⒋嵵緔 提交于 2021-02-18 18:09:52
问题 I am building a product configuration module which requires that multiple transparent PNGs of the same size (which represent product parts) be flattened onto one image. At first I tried this which made the composition of the 3 images but on a black background: <?php $x = 500; $y = 500; $final_img = imagecreatetruecolor($x, $y); $images = array('1.png', '2.png', '3.png'); foreach ($images as $image) { $image_layer = imagecreatefrompng($image); imagecopy($final_img, $image_layer, 0, 0, 0, 0, $x

PHP: how to express “near white” as a color?

北城以北 提交于 2021-02-16 16:31:07
问题 I have a function for trimming white areas around images that works something like if(imagecolorat($img, $x, $top) != 0xFFFFFF) { //sets where the top part of the image is trimmed } The problem is some images have an occasional stray pixel that is so near white that it's unnoticeable but screws up the cropping because it's not exactly 0xFFFFFF but 0xFFFEFF or something. How could I rewrite the above statement so that it evaluates true for those near white images, say down to 0xFDFDFD,

How to install/enable GD in xampp windows [php 7.2]?

假装没事ソ 提交于 2021-02-16 13:55:51
问题 I Can't figure out how to install php-gd for PHP7.2. Is there any way to install/enable GD extension in xampp windows? I checked the php.ini file for php_gd2.dll but I can't find that line. It seems like GD is missing in PHP7.2. Any suggestions?? 回答1: Under xampp/php/php.ini look for "extension=gd2" and uncomment it, I presume this what you looking for 回答2: go to php.ini file search this ;xtension=gd remove ; then 来源: https://stackoverflow.com/questions/55474258/how-to-install-enable-gd-in

Copy an image and preserve its EXIF/IPTC data with PHP imageCreateFromJpeg?

三世轮回 提交于 2021-02-16 05:55:07
问题 I having some problems with an image that has EXIF/IPTC data stored in it. When I use imageCreateFromJpeg (to rotate/crop or etc) the newly stored file doesn't preserve the EXIF/IPTC data. My current code looks like this: <?php // Before executing - EXIF/IPTC data is there (checked) $image = "/path/to/my/image.jpg"; $source = imagecreatefromjpeg($image); $rotate = imagerotate($source,90,0); imageJPEG($rotate,$image); // After executing - EXIF/IPTC data doesn't exist anymore. ?> Am I doing

Converting PNG to JPEG file

南笙酒味 提交于 2021-02-11 17:56:45
问题 I have a script to convert PNG files to JPEG files. Except, I'm not exactly sure how it works. What do use for $outputPngFile and $outputJpgFile? Can I do this with a tmp file, like when the user is uploading it? Then, how do I access the new file to move it to the proper image directory? function pngTojpg($image, $outputPngFile, $outputJpgFile, $quality) { $image = imagecreatefrompng($image); //Save the png image imagepng($image, $outputPngFile); //Save the jpeg image imagejpeg($image,

Problem to compile a C-program by GCC with GD2 library installed via MacPorts

两盒软妹~` 提交于 2021-02-11 12:50:37
问题 I have successfully compiled a C-program by GCC on Mac with GD2 library installed directly from sources. Now I am trying to do that with GD2 library installed via MacPorts and have the following error message: plotgeometry.c:5:16: error: gd.h: No such file or directory plotgeometry.c: In function 'PlotGeometry': plotgeometry.c:28: error: 'gdImagePtr' undeclared (first use in this function) plotgeometry.c:28: error: (Each undeclared identifier is reported only once plotgeometry.c:28: error:

Problem to compile a C-program by GCC with GD2 library installed via MacPorts

Deadly 提交于 2021-02-11 12:50:08
问题 I have successfully compiled a C-program by GCC on Mac with GD2 library installed directly from sources. Now I am trying to do that with GD2 library installed via MacPorts and have the following error message: plotgeometry.c:5:16: error: gd.h: No such file or directory plotgeometry.c: In function 'PlotGeometry': plotgeometry.c:28: error: 'gdImagePtr' undeclared (first use in this function) plotgeometry.c:28: error: (Each undeclared identifier is reported only once plotgeometry.c:28: error:

Writing text on image using GD is not working

微笑、不失礼 提交于 2021-02-11 06:55:27
问题 I'm using PHP 7.4 and when i try to write text on image using imagettftext() function nothing happen only blank image! when i roll back to PHP 5.6 it works perfect. I've confirmed that GD is enabled and i'm under windows OS Here is my code (i have copied it from php.net): // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128,